This Program will tell you whether number is prime or not...
#include <iostream>
using namespace std;
int main(){
int x, y, sum;
cout << "Enter the desired numbrer ";
cin >>x;
sum = 0;
y = x / 2;
for (int i = 1; i <= y; i++)
{
sum = sum + i;
}
if (sum > 1)
cout << "The number is not prime"<<endl;
else
cout << "The number is prime"<<endl;
return 0;
}
No comments:
Post a Comment