C program to find biggest number from three number by using
nested if statement
Problem Description
This program takes the 3 numbers and finds the biggest among all.
Problem Solution
1. Take the three numbers as input.
2. Check the first number if it greater than other two.
3. Repeat the step 2 for other two numbers.
4. Print the number which is greater among all and exit.
2. Check the first number if it greater than other two.
3. Repeat the step 2 for other two numbers.
4. Print the number which is greater among all and exit.
Program codes:-
here the program of finding biggest of three number run this in your Linux, DEV C++,turbo c++
#include<stdio.h>main()
{
int num1,num2,num3,big;
printf("enter the value for num1:");
scanf("%d",&num1);
printf("enter the value for num2:");
scanf("%d",&num2);
printf("enter the value for num3:");
scanf("%d",&num3);
if(num1>num3)
{
if(num1>num3)
big=num1;
else
big=num3;
}
else
{
if(num2>num3)
big=num2;
else
big=num3;
}
printf("biggest no=%d",big);
}
Program explanation:-
1. Take the three numbers and store it in the variables a,b,c respectively.for example we take num1=3,num2=2, num3= 4
2. Firstly check if the num1 is greater than num2.
3. If it is, then check if it is greater than num3.
4. If it is, then print the output as “num1 is the greatest among three”.
5. Otherwise print the ouput as “num3 is the greatest among three”.
6. If the num1 is not greater than num2, then check if num2 is greater than num3.
7. If it is, then print the output as “num2 is the greatest among three”.
Output of this program:-
Comments
Post a Comment
please subscribe my blog and let me suggest how I improve this site