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

Write a program that checks whether a given integer is even or odd. Take the input from the user and use an appropriate data type for the variable.

#include <stdio.h>

int main() {
// Declare variables to store user input
int number;

// Input: Get an integer from the user
printf(“Enter an integer: “);
scanf(“%d”, &number);

// Check whether the number is even or odd
if (number % 2 == 0) {
printf(“%d is an even number.n”, number);
} else {
printf(“%d is an odd number.n”, number);
}

return 0; // Exit the program successfully
}