Home » C Programming » Decision Making » Question
  1. What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input).
    #include <stdio.h>
    int main()
    {
    int var;
    printf("Enter a value between 1 to 2: ");
    scanf("%d", &var);
    switch (var, var + 1)
    {
    case 1:
    printf("Option 1.");
    break;
    case 2:
    printf("Option 2.");
    break;
    default :
    printf("Default option.");
    }
    }
    1. Option 1.
    2. Option 2.
    3. Default option.
    4. Compilation Error
    5. None of these
Correct Option: C

Default option.



Your comments will be displayed only after manual approval.