Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

C program that uses a function to check whether a given number is even or odd.

#include <stdio.h>

// Function to check if a number is even or odd
void checkEvenOdd(int num) {
if (num % 2 == 0) {
printf(“%d is an even number.n”, num);
} else {
printf(“%d is an odd number.n”, num);
}
}

int main() {
int number;

// Taking input for the number
printf(“Enter an integer: “);
scanf(“%d”, &number);

// Calling the function to check if the number is even or odd
checkEvenOdd(number);

return 0;
}