• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Storage Classes and Type Qualifiers

Question 31

Consider the following code:

C++
int a, b, c = 0;

void prtFun(void);

void main()
{
    static int a = 1;
    prtFun();
    a += 1;
    prtFun() printf("\n %d %d ", a, b);
}

void prtFun(void)
{
    static int a = 2;
    int b = 1;
    a += ++b;
    printf("\n %d %d ", a, b);
}

What output will be generated by the given code d\\segment if: 
Line 1 is replaced by “auto int a = 1;” 
Line 2 is replaced by “register int a = 2;” (GATE CS 2012) 
 

  • 3 1

    4 1

    4 2

     

  • 4 2

    6 1

    6 1

     

  • 4 2

    6 2

    2 0

     

  • 4 2

    4 2

    2 0

     

There are 31 questions to complete.

Last Updated :
Take a part in the ongoing discussion