New course! Every coder should learn Generative AI!
Try a free lesson0
C++
Write a program to check if the number is even or odd. Take an integer input from the user, if it is even print "even", otherwise print "odd". Sample Input 25 Sample Output odd Attempt in comments
4 Answers
+ 4
Mando dude what will be the number here (number%25)??
Check 25 or any other number for even or odd by taking its modulus with 2
like --> (25%2==0)cout<<"even";
else cout<<"odd";
Other way Martin mentioned is:
int number=25;
if(number & 1)
cout<<"odd";
else
cout<<"even";
0
#include <iostream>
using namespace std;
int main() {
int number;
cin>>number;
if (number<25) {
cout << "even";
}
else {
cout << "odd";
}
return 0;
}
0
So (number%25)?