HelpMeOutAlways: C Programs If-else
Showing posts with label C Programs If-else. Show all posts
Showing posts with label C Programs If-else. Show all posts

Saturday, August 25, 2018

Sunday, June 3, 2018

C Program To Find Maximum Among Three Numbers(Integers) Using Nested if-else Statement
June 03, 20180 Comments
//find maximum number among three integers
#include<stdio.h>
main()
{
int n1,n2,n3,max; //Declaration of variables
printf("Enter any three integers:\n");
scanf("%d%d%d",&n1,&n2,&n3);// Read three numbers from user
if(n1>n2) //let(condition 1)
{
if(n1>n3)//let (condition 2)
{

max=n1;} //if condition 1 and 2 are true then n1 is maximum
else{
max=n3; //if condition 1 is true but condition 2 is not true then max=n3
}
}
else
{
if(n2>n3){//let (condition3) if condition1 and condition2 are both false then condition 3 will execute i.e max=2

max=n2;}
else
{max=n3;//if conditon 1,2,3 are false then max=n3
}
}
printf("maximun from above three integers is=%d",max);//Show the maximum number to the outside world
return 0;
}
nested if- else

Reading Time:

@way2themes