Wednesday, April 22, 2020

Call by reference in C



  • Flowchart :


  • Program :

#include<stdio.h>
#include<conio.h>
void swapnum ( int *var1, int *var2 )
{
   int tempnum ;
   tempnum = *var1 ;
   *var1 = *var2 ;
   *var2 = tempnum ;
}
void main( )
{
   int num1 = 35, num2 = 45 ;
   clrscr();
   printf("\n----------------CALL BY REFERENCE----------------");
   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);
   getch();
}




  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...