Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following C program.
    #include
    int f1(void);
    int f2(void);
    int f3(void);
    int x = 10;
    int main ()
       {
        int x = 1;
        x + = f1 () + f2 () + f3() + f2();
        pirntf (“%d”, x);
        retirm 0;
      }
    int f1 () {int x = 25; x++; return x;}
    int f2 () {static int x = 50; x++; return x;}
    int f3 () {x *= 10; return x};
    The output of the program is ____.
    1. 320
    2. 130
    3. 230
    4. None of the above
Correct Option: C

In function main x will be updated as follows

x = x + f1 () + f2 () + f3 () + f2 ()x
1265110052

Note: static variable in f2 () will be initialized only once & it retains value in between function calls.



Your comments will be displayed only after manual approval.