C Program to find Smallest number among three

In this tutorial, we are going to learn the writing program in C to find the smallest number among 3 given integers.

So here our problem statement is, we have given 3 integers and we have to find the smallest number among three.

For Example

We Will Give 3 integers like 4,1,9. Here we will get output 1 because 1 is the smallest among three.

How our program will behave?

  • Program will take 3 integers as an input and it will return 1 integer as an output which will be smallest/minimum.
  • We are using if else statement to compare the elements.
  • Our logic is like we will pick one element and compare it with the rest two. If picked integer is smallest then we will print that picked number as smallest number. If not then we will pick another number and compare it with others two.

C Program to find Smallest number among three

#include<stdio.h>
void main(){
	int a,b,c;
	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 && a<=c)
		printf(" a = %d is smallest",a);
	if(b<=a && b<=c)
		printf("b = %d is smallest",b);
	if(c<=a && c<=b)
		printf("c = %d is smallest",c);
}

Output

C Program to find Smallest number among three

Share on

Also Prepare Below Important Question

Interview Questions Categories

C Programming Interview Preparation

Core Java Programming Interview Preparation

Python Programming Interview Preparation