Home » C Programming » Decision Making » Question
  1. What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input).
    #include <stdio.h>
    void main()
    {
    char *n;
    printf("Enter a value between 1 to 3:");
    scanf("%s", n);
    switch (n)
    {
    case "1":
    printf("Hey");
    break;
    case "2":
    printf("Hello");
    break;
    }
    }
    1. Hey
    2. Hellow
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: C

Compilation Error

error: '::main' must return 'int'
void main()
In function 'int main()':
error: switch quantity not an integer
switch (ch)



Your comments will be displayed only after manual approval.