+ 1

Why d is not printing when it is largest

#include <stdio.h> int main(){ int a, b, c, d; printf("Enter 4 numbers: \n"); scanf("%d %d %d %d", &a, &b, &c, &d); if (a >= b && a >= c) printf("%d is the largest number", a); else if (b>= a && b >= c) printf("%d is the largest number", b); else if (c >= a && c >= b) printf("%d is the largest number", c); printf("%d is the largest number", d); return 0; }

8th May 2021, 9:33 AM
ROHAN GUPTA
ROHAN GUPTA - avatar
3 Answers
0
Include d also in the conditions(comparision) and keep the final printf in else block.
8th May 2021, 9:40 AM
sarada lakshmi
sarada lakshmi - avatar
+ 1
Hii ROHAN GUPTA. You have to compare a, b and c with d. Add these conditions - a>=d b>=d c>=d And your problem will be solved. https://code.sololearn.com/c6MjQQF0W1s2/?ref=app
8th May 2021, 11:42 AM
Indian
Indian - avatar
0
Thanks "Sarada lakshmi"
8th May 2021, 9:47 AM
ROHAN GUPTA
ROHAN GUPTA - avatar