Home » C Programming » Input & Output » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    short int num;
    scanf("%h*d", &num);
    printf("%hd", h);
    return 0;
    }
    1. Undefined behavior
    2. Compilation Error
    3. Runtime Error
    4. Somegarbage value
    5. None of these
Correct Option: B

Compilation Error

main.c: In function ‘main’:
main.c:6:23: error: ‘h’ undeclared (first use in this function)
printf("%hd", h);
^
main.c:6:23: note: each undeclared identifier is reported only once for each function it appears in



Your comments will be displayed only after manual approval.