Biggest of 3 Numbers: C program
ฝัง
- เผยแพร่เมื่อ 7 ก.ย. 2024
- technotip.com/6...
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
technotip.com/6...
C Programming: Beginner To Advance To Expert
technotip.com/6...
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*
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.
It is not correct if a and b are the same and c is lesser. It should be like that:
if ((a >= b) && (a >= c)) {
printf("%d is the largest.", a);
} else if ((b >= a) && (b >= c)) {
printf("%d is the largest.", b);
} else {
printf("%d is the largest.", c);
}
Im going to tell a simple but noob way:
if(a>b)
{
printf("Big number is: %d",a);
}
else if(ac)
{
printf("Big number is: %d",b);
}
else
{
printf("Big number is: %d",c);
}
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.
Right bro, bros code is wrong 😂😂
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.
Which software are you using for command writing
Hope that helps: technotip.com/6094/the-best-ide-for-c-programming/
aj mei ne kiya board me to bikul sahi ho gya❤
WRONG
Galt hai bro tera program 😂
this is wrong code,the correct code is
#include
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
", a);
} else if (b >= a && b >= c) {
printf("%d, b is the greatest
", b);
} else {
printf("%d, c is the greatest
", c);
}
return 0;
}