C Programming :: Control Instructions - Discussion
Home > C Programming > Control Instructions > MCQs Questions Discussion
497 / 33
What will be the result of the following program?
#include <stdio.h>
int main()
{
int ones, twos, threes, others;
int c;
ones = twos = threes = others = 0;
while ((c = getchar ()) != EOF)
{
switch (c)
{
case '1': ++ones;
case '2': ++twos;
case '3': ++threes;
break;
default: ++others;
break;
}
}
printf ("%d %d", ones, others);
return 0;
}
#include <stdio.h>
int main()
{
int ones, twos, threes, others;
int c;
ones = twos = threes = others = 0;
while ((c = getchar ()) != EOF)
{
switch (c)
{
case '1': ++ones;
case '2': ++twos;
case '3': ++threes;
break;
default: ++others;
break;
}
}
printf ("%d %d", ones, others);
return 0;
}
A1 1
B3 4
C3 2
D3 3
EError
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
No Discussion on this question yet!