Clouds
Home
Tutorial of C language
Computer Language
Introduction to C
Programming in C
Structure of C program
Variable in C
Datatypes in C
Token in C
Operator in C
Precedence of C Operator
Assignment Operator in C
Logical Operator in C
Bitwise Operator in C
Ternary Operator in C
C Input Output
Pointers in C
Storage Classes of C
Control Structure of C
C Decision Making Statement
C Looping Statement
C Jumping Statement
C Function
Function Call By Value
Function Call By Reference
C Input Output Function
C Structure
Array in C
Union in C

Call-by-Reference

In a Call-by-reference technique a reference (Address) is being passed as an arguments to called function which in return required reference (Address).

Example1:-

				#include<stdio.h>
				#include<conio.h>
				void sum(int *a, int *b)
				{
				 	int sum=*a+*b;
				 	printf("Sum of a & b= %d",sum);
				}
				void  main()
				{
				 	int m,n;
					clrscr();
				 	printf("Enter the value of m: ");
				 	scanf("%d",&m);
				 	printf("Enter the value of n: ");
				 	scanf("%d",&n);
				 	sum(&m,&n);
					getch();
				}
				

Example2:-

				#include<stdio.h>
				void high(int *a,int *b)
				{
				 	if(*a>*b)
				 		printf("Highest value=%d",*a);
				 	else
				 		printf("Highest value=%d",*b);
				}
				void main()
				{
				 	int m,n;
				 	printf("Enter the value of m: ");
				 	scanf("%d",&m);
				 	printf("Enter the value of n: ");
				 	scanf("%d",&n);
				 	high(&m,&n);
				}
				

Example3:-

				#include<stdio.h>
				#include<conio.h>
				void swap(int *a,int *b)
				{
				 	int tmp=*a;
				 	*a=*b;
				 	*b=tmp;
				 	printf("1st No=%d\n",*a);
				 	printf("2nd N0=%d\n",*b);
				}

				void  main()
				{
				 	int m,n;
					clrscr();
					printf("Enter the 1st No.: ");
				 	scanf("%d",&m);
				 	printf("Enter the 2nd No.: ");
				 	scanf("%d",&n);
				 	swap(&m,&n);
					getch();
				}
				

C Input Output Function >>
C Structure >>
Array in C >>
Union in C >>
Computer Language >>


Home Clouds