Answer to Question #43884 in C++ for pooja bagde

Question #43884
write a programme using switch case for to check whether no. is even or odd
1
Expert's answer
2014-07-02T14:18:11-0400
#include<iostream>

using namespace std;
//main function
int main()
{
//loop from 0 to 9 number and check if number is odd or even
for(int i=0;i<10;i++){
// using switch case for to check whether no. is even or odd
switch(i%2){
case 0:
//show result
cout << "The number "<<i<<" is even\n";
break;
default:
cout << "The number "<<i<<" is odd\n";
}
}
//delay
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS