Question: Write a program to determine if a number is even or odd. Hint: use the modulo operator. Apparently printf and scanf are not C++(even though
Write a program to determine if a number is even or odd. Hint: use the modulo operator.
Apparently printf and scanf are not C++(even though I know it can be).
How else could I write this in C++
Here's an example of my code:
#include
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
