When I compile this little program instead of displaying "num1:7
, num2: 2
",
it displays "num1:-1218690218
, num2:-1217453276
". I think I'm not specifying what the program should display so its just giving me the int range instead.
I'm sorry.
#include <stdio.h>
main() {
int num1 = 7, num2 = 2;
printf("num1:%d , num2:%d\n"), num1, num2;
}
EDIT: Thank you so much! The purpose of the exercise was to correct syntax errors, but whenever I compiled it I never got any warnings. That parenthesis is so easy to miss.
You've put the closing parenthesis before num1
and num2
, so they're not being passed to printf
. You need to change this:
printf("num1:%d , num2:%d\n"), num1, num2;
to this:
printf("num1:%d , num2:%d\n", num1, num2);
Yes, the parenthesis is the only change, but it's crucial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With