475,521 views
6 votes
6 votes
What is the result of the following code?

int x = 1;
switch(x)
{
case 1: printf( "Help" );
case 0: printf( "Me" );
break;
case 2: printf( "Hello World" );
}
A. HelpMe
B. Help
C. Help Me
D. Hello World

User Cardell
by
2.8k points

1 Answer

12 votes
12 votes

Answer:

B: Help

Step-by-step explanation:

During the execution of this switch statement, it will print "Help" because that's the only case that matches the value of x, it will not print "Me" because that case does not match, so it will fall through that case into the break statement.

User Stylize
by
2.6k points