How to check whether numbers is greater or smaller in c?

In this section you will learn how to find whether a number is greater or small in c. We will use if else condition to check the greater or smaller number and we will show the result on output screen. In this program we are taking the input from user.

Greate or Small Number Program

Let’s suppose a user will input two numbers as '6' and '7' then as result it will show 6 is small and 7 is greater.

How program will work?

Program to find greater and smallest number in c


	#include<stdio.h>
	#include<conio.h>

	//GREATER & SMALLER NUMBER PROGRAM
	void main()
	{
		int a,b;
		clrscr();
		printf("ENTER THE FIRST NUMBER:- ");
		scanf("%d",&a);
		printf("ENTER THE SECOND NUMBER:- ");
		scanf("%d",&b);
		
		if(a>b)
		{	
			printf("%d NUMBER IS GREATER AND %d NUMBER IS SMALLER.",a,b);
		}
		else
		{
			printf("%d NUMBER IS GREATER AND %d NUMBER IS SMALLER.",a,b);
		}

	getch();
	}

Output:


	ENTER THE FIRST NUMBER:- 6
	ENTER THE SECOND NUMBER:- 7
	7 NUMBER IS GREATER AND 6 IS SMALLER.

Post Your Comment