Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Call by reference in User-defined Functions of Programming in C
2300 Views
Call by reference 
Passing some arguments to a function using pointer reference, it is known as call by reference. It is modifiable by the calling function.
Program
	#include
	void swap(int *,int *);
	void main(){
	   int a = 10;
	   int b = 20;
	   clrscr();
	   printf("Before\n");
	   printf("A = %d;B = %d\n",a,b);
	   swap(&a,&b);
	   printf("After\n");
	   printf("A = %d;B = %d\n",a,b);
	}
	void swap(int *x,int *y){
	   int tmp = *x;
	   *x = *y;
	   *y = tmp;
	    printf("After done swaping inside swap function\n");
	    printf("A = %d;B = %d\n",*x,*y);
	}
Output 
Before
A = 10;B = 20
After done swaping inside swap function
A = 20;B = 10
After
A = 20;B = 10
Next Topics
Next lessons of current book.
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Previous Topics
Previous lessons of current book.
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details