Page

C Program To swap two number by using call by reference

#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2;
void swap(int*,int*);
clrscr();
printf("Enter two integers:");
scanf("%d%d",&num1,&num2);
swap(&num1,&num2);
printf("\after swapping numbers are%d%4d\n",num1,num2);
getch();
}
void swap(int*a,int*b)
{
int temp=*a;
*a=*b;
*b=temp;
}


No comments:

Post a Comment