PrimeNumberProgram - if (ans == 0) cout<<"The...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> #include <iomanip> #include <cmath> using namespace std int IsPrime(int num) { int ans=1 for(int i = 2 i <= num/2 i++) { if(num % i == 0) { ans = 0 break } } return ans } int main () { int Number char ContinueLoop = 'Y' while (ContinueLoop == 'Y') { cout <<endl<<endl <<"Please enter a number: " cin >> Number c { int ans = IsPrime(Number)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (ans == 0) cout<<"The number is not a prime number" else cout<<"The number is a prime number" } cout<<"\nDo you want to continue? (Y) " cin>>ContinueLoop cout<<endl ContinueLoop = toupper(ContinueLoop) }//end of ContinueLoop } cout<<"\nGood-bye!" return 0 }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Ask a homework question - tutors are online