Min of Three Numbers

Write a program that inputs three numbers and outputs the smallest   number using nested if-else statement.


Source Code:

#include<stdio.h>
#include<conio.h>
void main()
{
	int a,b,c;
	clrscr();
	printf("Enter the value of a:");
	scanf("%d",&a);
	printf("enter the value of b:");
	scanf("%d",&b);
	printf("enter the value of c:");
	scanf("%d",&c);

	if(a<b)
	{
		if(a<c)
		{
			printf("a is minimum");
		}
		else
		{
			printf("c is minimum");
		}
	}
	else
	{
		if(b<c)
		{
			printf("b is minimum");
		}
		else
		{
			printf("c is minimum");
		}
	}
	getch();
}

Output:

Enter the value of a: 10
Enter the value of b: 20
Enter the value of c: 30

A is minimum

Enter the value of a: 30
Enter the value of b: 20
Enter the value of c: 10

C is minimum

Leave a Reply

Your email address will not be published. Required fields are marked *