C Programming

Solved Example

Practice Questions

Exercise Question

Check a number is even or odd

Objective

Input a number and check the number is even or odd.

Program / Solution:

#include<stdio.h>
int main() {
	int n;
	printf("Enter any number: ");
	scanf("%d",&n);
	
	if(n % 2 == 0) {
		printf("%d is even",n);
	}else {
		printf("%d is odd",n);
	}
	return 0;
}
#include<stdio.h>
int main() {
	int n;
	printf("Enter any number: ");
	scanf("%d",&n);
	
	if(n % 2) {
		printf("%d is odd",n);
	}else {
		printf("%d is even",n);
	}
	return 0;
}

Sample Output:

Enter any number: 52
52 is even

More Progarms of Decision Making in C

Calculate profit or loss

Check a number is positive or negative

Check a year is leap year or not

Find the first day of year

Find the youngest person

Absolute value of a number

Find area of rectangle is greater than perimeter

Check the points are co-linear or not

Check a point is inside,outside or on the circle

Check the axis of a point

Identify a character is alphabet, digit and more

Check the insurance eligibility and calculate premium

Calculate the library penalty charges

Calculate grade of a student