Ask your own question, for FREE!
Computer Science 25 Online
OpenStudy (anonymous):

how to write a c++ program to check whether a given number is prime or not?

OpenStudy (anonymous):

Here is the algorithm http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Try to understand the logic, start writing the program, and i am sure people will help you here if you get stuck -_-

OpenStudy (anonymous):

At what point are you having difficulties, with the language, the algorithm, or compliation?

OpenStudy (anonymous):

int num,i,flag=1; cin>>num; for(i=num;i>0;i--) { if(i%num ==0) {flag=0;} } if(flag == 0) {cout<<"composite";} if(flag == 1) {cout<<"prime";}

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!