[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

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;
    }

A1 1

B3 4

C3 2

D3 3

EError

Answer: Option (Login/Signup)

Show Explanation

Asked In :: TCS

Post Your Answer Here:     

No Discussion on this question yet!