+ 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
0
Thanks "Sarada lakshmi"
8th May 2021, 9:47 AM
ROHAN GUPTA
ROHAN GUPTA - avatar