edited by
8,799 views
29 votes
29 votes

The value printed by the following program is _______.

      void f (int * p, int m) { 
           m = m + 5; 
          *p = *p + m; 
           return; 
      }  
      void main () { 
       int i=5, j=10; 

       f (&i, j); 
       printf ("%d", i+j); 
     }
edited by

7 Answers

0 votes
0 votes


P is a pointer stores the address of i, & m is the formal parameter of j.
Now, m = m + 5;
*p = *p + m;

Hence, i + j will be 20 + 10 = 30.

0 votes
0 votes

 

This program output will solve the doubt related to f(&i,j) working:

 
#include <stdio.h>


   void f (int * p, int m) { 
           m = m + 5; 
           printf("m =%d",m);
           
          *p = *p + m;
          printf(" *p =%d",*p);
           return; 
      }  
      void main () { 
       int i=5, j=10; 

       f (&i, j); 
       printf("\ni & j value after call i=%d j=%d ",i,j);
       printf ("\nlast output i+j=%d", i+j); 
     }

Answer:

Related questions