hello my first post here,i am having problem with this program and i am a new to c++ too,my apologies if i posted in wrong section.
Well here is the program i have done so far:
also i am using dev c++ compiler.
#include <iostream>
usingnamespace std;
int main ()
{
int b,a,r=0;
cout<<"input the number you want to test";
cin>>a;
for (b>1;b<a;b++);
{if (a%b==0)
{cout<<a<<"is not prime";
r++;
}
}
if (r==0)
{
cout<<a<< "is prime number";
}
if (r!=0)
{
cout<<a<< "is not prime number";
}
system ("PAUSE");
return 0;
}
Output is
5 is a prime number5 is not a prime number press any key to continue
#include <iostream>
usingnamespace std;
int main ()
{
int b,a,r=0;
cout<<"input the number you want to test";
cin>>a;
for (b=2;b<a;b++)
{if (a%b==0)
{cout<<a<<"is not prime";
r++;
}
}
if (r==0)
{
cout<<a<< "is a prime number";
}
if (r!=0)
{
cout<<a<< "is not a prime number";
}
system ("PAUSE");
return 0;
}