i just started learning C, but after i finished writing this programme, it wouldn't respond to the number that i had entered. can anyone please tell me what is going on? thx!
can anyone please tell me what is wrong with this programme i wrote?
Collapse
X
-
It works for me. What exactly is the problem you are facing. Better initialize all the local variables i, num1, num2 to 0. -
you need to put your case in parenthesis
case 1:
{
num1=....
num2=.....
printf.....
}
break;
also try to initialize all int to zero
like this
i=num1=num2=0;Comment
-
- Catch and print the return value from scanf (at least for debugging purposes).
- Terminate your puts strings with newline ('\n'). This is helpful when stdio uses buffered I/O.
- Notice that if the number is even you fall out of main rather than loop back to enter a new value.
Putting braces around the cases won't change anything.Comment
Comment