Home » C Programming » Variables » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    register int P = 50;
    function();
    printf("P is %d", P);
    }
    void function()
    {
    P++;
    }
    1. 51
    2. Garbage value
    3. Compilation Error
    4. 50
    5. None of these
Correct Option: C

Compilation Error

main.c: In function ‘main’:
main.c:5:9: warning: implicit declaration of function ‘function’ [-Wimplicit-function-declaration]
function();
^~~~~~~~
main.c: At top level:
main.c:8:10: warning: conflicting types for ‘function’
void function()
^~~~~~~~
main.c:5:9: note: previous implicit declaration of ‘function’ was here
function();
^~~~~~~~
main.c: In function ‘function’:
main.c:10:9: error: ‘P’ undeclared (first use in this function)
P++;
^
main.c:10:9: note: each undeclared identifier is reported only once for each function it appears in



Your comments will be displayed only after manual approval.