Largest between two no in c (if-else)

Syntax of if-else in c:

if( expression.....)
{
    work if that expression inside the if parenthasis be true .....
}
else if (expression........)
{
    work if that expression inside the else if parenthasis be true .....
}
else
{
    if that expression inside the if and else if parenthasis not be true .....
}

Little bit about if-else if-else:

We do conditional programming work with the help of if “-else if -else “. If that expressions(or mathemathical condition) inside the parenthasis is true then enter the respective block and do work according to the direction.

FIND LARGE NUMBER BETWEEN TWO USING IF-ELSE

  • Take two number a and b from the user
  • let user give a=20 and b=23
  • check (a>b): if true the a big and if that expression false then it goes to else block
  • This way it works………………..
#include<stdio.h>
 int main()
 {
     float a,b,big;
     printf("\tEnter a value of a : ");
     scanf("%f",&a);
     printf("\tEnter a value of b : ");
     scanf("%f",&b);
     if(a>b)
     {
          printf("\tBig=%.3f",a);
     }
     else
       {
             printf("\tBig=%.3f",b);
         }
    
  return 100;
 }

I think confusion over if – else if – else in c is gone. Any doubt please write in the comment section below…..

3 comments

Leave a comment