//Program to pass pointer to the function.
#include<stdio.h>
#include<conio.h>
//Declaring the swap function.
void swap(int *ptr,int *ptr1);
//Main function.
void main()
{
int a,b;
clrscr();
printf("Enter value of a:");
scanf("%d",&a);
printf("\nEnter value of b:");
scanf("%d",&b);
swap(&a,&b);
printf("\nAfter swapping, values of a & b:%d & %d respectively\n",a,b);
getch();
}//end of main
//Definition of swap function.
void swap(int *ptr,int *ptr1)
{
int temp;
temp=*ptr;
*ptr=*ptr1;
*ptr1=temp;
}
/*Output of Program
Enter value of a:67
Enter value of b:89
After swapping, values of a & b:89 & 67 respectively */
Pankaj Gaikar is a
professional blogger
from Pune, India who writes on Technology, Android,
Gadgets, social media and latest tech updates at
Punk Tech
,
Being Android
&
Shake The Tech
. Email me
HERE
0 comments :
Post a Comment