Interview Questions

What will be printed as the result of the operation below: int x;..

C Interview Questions and Answers


(Continued from previous question...)

What will be printed as the result of the operation below: int x;..

What will be printed as the result
of the operation below:

          int x;
          int modifyvalue()
          {
              return(x+=10);
          }

          int changevalue(int x)
          {
              return(x+=1);
          }

          void main()
          {
              int x=10;
              x++;
              changevalue(x);
              x++;
              modifyvalue();
              printf("First output:%d\n",x);

              x++;
              changevalue(x);
              printf("Second output:%d\n",x);
              modifyvalue();
              printf("Third output:%d\n",x);

          }
      Answer: 12 , 13 , 13

(Continued on next question...)

Other Interview Questions