Write a function that check if a number is even.
Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
int isEven(int nb)
{
return !(nb%2);
}
void main()
{
int a;
printf("Enter an integer: ");
scanf("%d", &a);
if (isEven(a))
printf("%d is even.\n",a);
else
printf("%d is odd.\n", a);
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Ordering jobs