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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!