0

Some help

Pls

10th Jan 2023, 9:53 PM
Jerome
Jerome - avatar
6 Antworten
+ 2
Please mention the tag in what code problem #include <stdio.h> int main() { int temp; printf ("Enter the temperature\n"); scanf("%d",&temp); if(temp >=80){printf("swimming\n");} else if(60<=temp && temp<80){printf ("tennis\n");} else if(40<=temp && temp<60){printf ("golf\n");} return 0; } And use && operator and don't need to print else statement because you already mention in if statement, if(temp>=80).
11th Jan 2023, 5:57 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
You don't need double condition like 60<=temp||temp<80 etc.. #include <stdio.h> int main(void) { int temp; printf ("Enter the temperature\n"); scanf("%d",&temp); puts(temp > 79?"swimming\n": temp > 59?"tennis\n": temp > 39?"golf\n": "skying\n"); return 0; }
11th Jan 2023, 8:37 AM
Smith Welder
Smith Welder - avatar
+ 2
Thanks
11th Jan 2023, 1:33 PM
Jerome
Jerome - avatar
0
Hello. What do you need help with? Please specify
10th Jan 2023, 9:53 PM
Lamron
Lamron - avatar
0
#include <stdio.h> int main() { int temp; printf ("Enter the temperature\n"); scanf("%d",&temp); if(temp >=80){printf("swimming\n");} else if(60<=temp || temp<80){printf ("tennis\n");} else if(40<=temp || temp<60){printf ("golf\n");} else {printf ("skying\n");} return 0; }
10th Jan 2023, 9:55 PM
Jerome
Jerome - avatar
0
Can you correct it The golf and skying output doesn't go
10th Jan 2023, 9:56 PM
Jerome
Jerome - avatar