- 2
Any help please
I don't understand why it's not printing case 3. #include <stdio.h> main(){ int number=0; while(number<5) { switch (number) { default: printf("defualt\n"); case 0 : printf("cas 0\n"); break; case 3 : printf("cas 3\n"); break; case 2 : ++number; case -1 : printf("cas -1\n"); break; case 1 : printf("cas 1\n"); } ++number; } return 0; }
10 Answers
0
case 3 is not printed because in case 2 number is incremented to 3, but after the switch statement number is incremented again (to 4)
+ 3
Please don't just post code - communicate!
What is your code supposed to do?
What happens instead?
What have you tried to fix it?
How can we help you?
+ 2
what is wrong with that code?
a function must have a return type (void if it doesn't return something)
you returned 0 at the end of the code, so you should also add the return type (int) to de function definition
int main () {
...
+ 2
Mention complete detail what output you want through this code and what i have to fix in this code and choose relevant tag according to your problem.
0
The only thing I can see is "wrong/missing" is a "break" in case 2 so it falls though to case -1......but without knowing what you'r trying to do...It's had to say.
edit..and a "break" at the default as it's not at the end of the switch.
0
Just I found in axm
I don't understand why not printing case 3
0
What should be the output
0
You'r incrementing at case 2 as well as at the end.
0
@John Robotane
that's probably just missing when the code was mis-copied and pasted onto here.
0
ya