Write a program that reads an integer value x and displays whether x is an even or an odd number.


Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
int main()
{
	int x;

 	printf("Please an integer :");
 	scanf("%d", &x);

 	if (x%2==0)
     		printf("%d is even\n", x);
 	else
     		printf("%d is odd\n", x);

	return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Maximum width and depth