CODINGCLASSES|LEARNTOPROGRAM
PRIME NUMBER IN C++
PRIME NUMBER:-
A prime number is a whole number greater than 1,
whose only two whole-numberfactors are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. As we proceed in the set of natural numbers N = {1, 2, 3, ...}, the primes become less and less frequent in general.
E.G:-
PRIME NUMBER IN C++
PRIME NUMBER:-
A prime number is a whole number greater than 1,
whose only two whole-numberfactors are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. As we proceed in the set of natural numbers N = {1, 2, 3, ...}, the primes become less and less frequent in general.
E.G:-
#include<iostream.h>
#include<conio.h>;
void main()
{
int n, i, j=0;
cout << "Enter a positive integer: ";
cin >> n;
for(i=2; i<=n/2; i++)
{
if(n%i==0)
{
j=1;
break;
}
}
if (j==0)
cout << "This is your prime number";
else
cout << "This is not a prime number";
getch();
}
IN this CODE NOT ANY COMPILE AND RUN TIME ERROR this already checked in turboc++
No comments:
Post a Comment