Biggest of 3 Numbers: C program

preview_player
Показать описание


Lets write C program to find biggest of 3 numbers, using nested if statement.

Here first we check if a is greater than b. If yes, then we display a as big. Else b or c is biggest. So now we check if b is greater than c, if yes, we display b as biggest else c is biggest. Nested if else condition works great for programs like this.

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

sir you have written a>b in if-block but sir this isn't true because how will c's value compare !?
*if c would bigger than even it will say a is bigger i mean only if block execute*

noorgul
Автор

If(a>b&&a>c){
printf a is greter
}else if b>a&&b>c
printf b is greater
else
printf c is greater
I think this is correct. Sorry for not write properly.

rk
Автор

You are doing it wrong...
In your code,
If A is greater than B but less then C, it will show A as the largest number here.

BarkatUllahMahi-ft
Автор

how to find biggest number among three numbers if all given numbers are equal or same like a=11 and b=11 and c=11 how to aproach this type of problems.

Saయి
Автор

aj mei ne kiya board me to bikul sahi ho gya❤

IbrarHussain-ce
Автор

Which software are you using for command writing

shibashankarnayak
Автор

this is wrong code, the correct code is
#include <stdio.h>

int main() {
int a, b, c;
printf("Enter 3 numbers to compare: ");
scanf("%d%d%d", &a, &b, &c);

if (a >= b && a >= c) {
printf("%d, a is the greatest\n", a);
} else if (b >= a && b >= c) {
printf("%d, b is the greatest\n", b);
} else {
printf("%d, c is the greatest\n", c);
}

return 0;
}

sebinjoseph