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 1:
Enter the value of a: 12
Enter the value of b: 55
Enter the value of c: 34
a = 12 is smallest
Output 2:
Enter the value of a: 34
Enter the value of b: 66
Enter the value of c: 74
a = 34 is smallest
Also Prepare Below Important Question
- Python Program to add two number using Recursion
- Python Program to Find Highest Frequency Element in Array
- Python Program to Merge two Arrays
- Perform left rotation by two positions in Array Using Python
- Python Program to Delete Element at Given Index in Array
- Python Program to Delete element at End of Array
- Python Program to Copy one String to Another String
- Python Program to Remove Repeated Character from String
- Print highest frequency Character in String in Python
- Python Program to Convert lowercase vowel to uppercase
- Convert Celsius to Fahrenheit in Python
- Leap Year Program in Python
- Python Program to convert Decimal to Octal number
- Python Program to Convert Decimal Number into Binary
- Find all Pairs Whose Sum is Equal to Given number in Python
- Python Program to Replace First Vowel With ‘-‘ in String
- Python Program to find Prime factors of given integer
- Python Program to Print Prime Number in given range
- Java Program to Perform Left Rotation on Array Elements by Two
- Java Program to Perform Right Rotation on Array Elements by Two
Interview Questions Categories
C Programming Interview Preparation
Core Java Programming Interview Preparation
- Core Java Programming Coding Questions
- Core Java Pattern Programming Questions
- Core Java Programming Interview Questions