Can someone please tell me what is wrong with this code, and how i should fix it.
if (waether == sunny)
if (day == saturday)
printf("go to the beach\n");
else
print("take your umbrella\n");
Can someone please tell me what is wrong with this code, and how i should fix it.
if (waether == sunny)
if (day == saturday)
printf("go to the beach\n");
else
print("take your umbrella\n");
There's a lot wrong with it, if saturday and sunny aren't variables. also, there's no "print" function - you want printf.
-Govtcheez
[email protected]
The logic doesn't look very good, anyway, is this what you
wanted to do ?
Code:if ((weather==sunny) && (day==saturday)) { printf("Go to the beach\n"); } else { printf("Take your umbrella\n"); }
>Can someone please tell me what is wrong with this code, and how i should fix it.
Make sure that your variables are all declared and spelled correctly, then change print to printf and place brackets around the first two if statements. An else will bind with the closest if, so your logic actually runs like this:
Judging from the messages, you want this to happen instead:Code:if ( weather == sunny ) { if (day == saturday) printf("go to the beach\n"); else printf("take your umbrella\n"); }
Otherwise you would take your umbrella when it's sunny on every day but Saturday.Code:if ( weather == sunny ) { if (day == saturday) printf("go to the beach\n"); } else printf("take your umbrella\n");
-Prelude
My best code is written with the delete key.