C Logical Programming – Biggest of 3 Numbers in C

This “Biggest of 3 Numbers in C” post explains clearly how to find biggest of three numbers using if-else-if ladder.


#include<stdio.h>
void main()
{
int a,b,c;
printf(“Enter 3 integers : “);
scanf(“%d%d%d”, &a , &b , &c);
if(a>b && a>c)
printf(“A is big”);
else if(b>a && b>c)
printf(“B is big”);
else if(c>a && c>b)
printf(“C is big”);
}


Note : Above application execution takes more time. We can re-write the program as follows

#include<stdio.h>
void main()
{
int a,b,c;
printf(“Enter 3 integers : “);
scanf(“%d%d%d”, &a , &b , &c);
if(a>b && a>c)
printf(“A is big”);
else if(b>c)
printf(“B is big”);
else
printf(“C is big”);
}

Share this