Function : A function is a group of statements that together perform a task.A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.
File Name : callbyreference.c
//program to swap two numbers using functions - callbyreference
#include<stdio.h>
void main()
{
int a=10,b=50;
void swap(int *,int *);
clrscr();
printf("Before Swapping: %d %d\n",a,b);
swap(&a,&b);
printf("After Swapping: %d %d\n",a,b);
}
void swap(int *a,int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
}
Output :
Before Swapping: 10 50
After Swapping: 50 10
File Name : callbyreference.c
//program to swap two numbers using functions - callbyreference
#include<stdio.h>
void main()
{
int a=10,b=50;
void swap(int *,int *);
clrscr();
printf("Before Swapping: %d %d\n",a,b);
swap(&a,&b);
printf("After Swapping: %d %d\n",a,b);
}
void swap(int *a,int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
}
Output :
Before Swapping: 10 50
After Swapping: 50 10