ADVERTISEMENT
ADVERTISEMENT

C - Assign values to variables through function by Call by Reference.


IncludeHelp 03 July 2016

Call by Reference - In this technique we pass address (pointer) of variables instead of actual variables, any changes made to the variables will reflect to actual variables.

In this code snippet program will assign values to the variables through function by using Call by References.

C Code Snippet - Assign Values to Variables using function - Call by Reference

/*C - Assign value to variables 
through function by Call by Reference.*/

#include <stdio.h>

void assignValues(int *x, int *y){
	*x=10;
	*y=20;
}

int main(){
	
	int a,b;

	//assigning values
	assignValues(&a,&b);

	printf("After assigning values from function a: %d, b: %d\n",a,b);
}
    After assigning values from function a: 10, b: 20

ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.