443,918 Members | 1,816 Online
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

# check if number is december

 P: n/a Hello, What shoud I change in this code to check, if some number is december: #include #include using namespace std; int main(){ int a,b; int n=2; int december=1; cin>>a; for(a/n;a
5 Replies

 P: n/a "veki" #include using namespace std; int main(){ int a,b; 'b' is never used in the program, what is it for? int n=2; int december=1; cin>>a; What should your program do if the user types in "hello" instead of a number? for(a/n;a

 P: n/a veki wrote: Hello, What shoud I change in this code to check, if some number is december: I have no idea what you mean by "some number is december". > #include #include using namespace std; int main(){ int a,b; You never use b. int n=2; int december=1; Looks like a better type for december would be bool. cin>>a; for(a/n;a

 P: n/a On Nov 12, 2:51 am, "Daniel T."

 P: n/a "veki" #include using namespace std; int main(){ int a,b; int n=2; int december=1; cin>>a; for(a/n;a int main(){ int Number; std::cout << "Enter number to check for prime:"; if ( std::cin >Number ) { bool Prime = true; // Guilty until proven innocent for( int i = 2; i < Number; i++){ if (Number%i ==0 ){ Prime = false; break; } } if ( Prime ) std::cout << "Number is prime\n"; else std::cout << "Number is not prime\n"; } return 0; } Nov 12 '07 #5

 P: n/a On 12 stu, 07:49, "Jim Langston" #include using namespace std; int main(){ int a,b; int n=2; intdecember=1; cin>>a; for(a/n;a int main(){ int Number; std::cout << "Enter number to check for prime:"; if ( std::cin >Number ) { bool Prime = true; // Guilty until proven innocent for( int i = 2; i < Number; i++){ if (Number%i ==0 ){ Prime = false; break; } } if ( Prime ) std::cout << "Number is prime\n"; else std::cout << "Number is not prime\n"; } return 0; } Hello, Thanks it was useful! Regards, Vedran Nov 16 '07 #6

### This discussion thread is closed

Replies have been disabled for this discussion.