adplus-dvertising
frame-decoration

Question

When 1 is entered, The output of the code below is?
#include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value btw 1 to 2:");
        scanf("%d", &ch);
        switch (ch)
        {
        case 1:
            printf("1\n");
        default:
            printf("2\n");
        }
    }

a.

1

b.

2

c.

1 2

d.

Run time error

Posted under C Programming

Answer: (c).1 2

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. When 1 is entered, The output of the code below is? #include <stdio.h> void main() { int ch; printf("enter a value btw 1 to 2:");...

Similar Questions

Discover Related MCQs

Q. if (a == 1||b == 2){} can be written as:

Q. Which of the following is an invalid if-else statement?

Q. Switch statement accepts

Q. The following code ‘for(;;)’ represents an infinite loop. It can be terminated by

Q. The correct syntax for running two variable for loop simultaneously is.

Q. Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?

Q. Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?

Q. Example of iteration in C

Q. Number of times while loop condition is tested is, i is initialized to 0 in both case.

while (i < n)
i++;
————-
do
i++;
while (i <= n);

Q. Which loop is most suitable to first perform the operation and then test the condition?

Q. Which keyword can be used for coming out of recursion?

Q. The keyword ‘break’ cannot be simply used within:

Q. Which keyword is used to come out of a loop only for that iteration?

Q. goto can be used to jump from main to within a function

Q. Which command is used to skip the rest of a loop and carry on from the top of the loop again?

Q. The type of the controlling expression of a switch statement cannot be of the type ........

Q. What's wrong in the following statement, provided k is a variable of type int?
for(k = 2, k <=12, k++)

Q. Consider the following program fragment. What would be the value of sum for the input 1, -1, 2, -2, 3, -3, 4, -4, 5, -5

Q. Which of the following is not logical operator?

Q. In mathematics and computer programming, which is the correct order of mathematical operators ?