108k views
21 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 Lonnie
by
4.9k points

1 Answer

10 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 Matt Campbell
by
4.1k points