Program:
//Program to swap element using pointer. By Slashmycode.com
#include<stdio.h>
#include<conio.h>
void swap(int *i,int *j);
int main(void)
{
int num1,num2;
num1=100;
num2=800;
clrscr();
printf("num1=%d num2=%d\n", num1,num2);
swap(&num1,&num2);
printf("num1=%d num2=%d\n", num1,num2);
//Program to swap element using pointer. By Slashmycode.com
getch();
}
void swap(int *i,int *j)
{
int temp;
temp=*i;
*i=*j;
*j=temp;
}
Output:
No comments:
Post a Comment
Feel free to ask us any question regarding this post