Sunday, November 15, 2020

#Program of Function call by Reference

 

#include <stdio.h>

#include<conio.h>

int swapnum ( int *a1, int *a2 )

{

   int tempnum ;

   tempnum = *a1 ;

   *a1 = *a2 ;

   *a2 = tempnum ;

}

int main( )

{

   int num1 = 35, num2 = 45 ;

   printf("Before swapping:");

   printf("\nnum1 value is %d", num1);

   printf("\nnum2 value is %d", num2);

 

   

   swapnum( &num1, &num2 );

 

   printf("\nAfter swapping:");

   printf("\nnum1 value is %d", num1);

   printf("\nnum2 value is %d", num2);

   return 0;

}

No comments:

Post a Comment

MCQ QUESTIONS

Loading…