The Wayback Machine - https://web.archive.org/web/20201209103917/https://github.com/churchdude77/ConsoleApplication12.cpp
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

README.md

ConsoleApplication12.cpp

/* Prime Number or Not */ #include<conio.h> #incude<math.h>

void main() {

int n, i = 2, flag = 0; clrscr();

cout << "Enter a positive integer value:"; cin >> n;

/* Loop to check whether 'n' is divisible by any number between 2 and sqrt(n) */ while (i <= sqrt(n)) { if (n % i == 0) { flag = 1; break; } i++; }

  /* if else condition to print Prime Number or Not */
  if (flag ==0)
      cout << n << "is a prime number.";
  else
      cout << n << "is not a prime number.";
   getch();
   
   return 0;

}

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.