PrimeNumberProgram1 - do { cout <<...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std int isPrime(long num) { if (num < 2) return 0 return 0 for(int i = 2 i < num i++ ) { cout << " divisor: " << i << endl if ( (num % i) == 0) { return 0 } } return 1 } int main() { int num
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: do { cout &lt;&lt; &quot;Please enter a number (0 to stop) &quot; &lt;&lt; endl cin &gt;&gt; num if (num) { if (isPrime(num)) cout &lt;&lt; num &lt;&lt; &quot; is a prime number &quot; &lt;&lt; endl else cout &lt;&lt; num &lt;&lt; &quot; is NOT a prime number &quot; &lt;&lt; endl } } while (num &gt; 0) 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