Programming Examples On Pointers
Programming Examples On Pointers
Vision: The Department of Computer Science and Engineering shall create professionally competent
and socially responsible engineers capable of working in global environment
3. C Program to perform swapping of two numbers using pass by reference (address by
reference)
#include<stdio.h>
void swap(int *p,int *q)
{
int temp;
temp=*p;
*p=*q;
*q=temp;
}
void main()
{
int a=20,b=40;
printf("Before swapping a=%d and b=%d\n",a,b);
swap(&a,&b);
printf("After swapping a=%d and b=%d\n",a,b);
}
Vision: The Department of Computer Science and Engineering shall create professionally competent
and socially responsible engineers capable of working in global environment