11: Write a program that takes an integer as input and prints whether it is even or odd
// Write a program that takes an integer as input and prints whether it is even or odd
#include<iostream>
using namespace std;
int main(){
int num;
cout << "Enter the number: ";
cin >> num ;
if(num % 2 == 0){
cout << "The number is 'even' \n \n";}
else cout << "The number is 'odd' \n \n";
cout << "Now you have your answer \n";
return 0;
}
Input 1:
Enter the number: 54
Output 1:
The number is 'even'
Now you have your answer
Input 2:
Enter the number: 67
Output 2:
The number is 'odd'
Now you have your answer
Comments
Post a Comment