C Program To Swap Two Numbers - Call By Reference

#include<conio.h>
#include<stdio.h>

void swap(int*a,int*b)

{

int temp;
temp=*a;
*a=*b;
*b=temp;

}

void main()

{

int num1,num2;
clrscr();
printf("Enter Value For Number 1 : ");
scanf("%d",&num1);
printf("Enter Value For Number 2 : ");
scanf("%d",&num2);
printf("\nNum1 : %d\tNum2 : %d",num1,num2);
swap(&num1,&num2);
printf("\n\nSwaping....\n\n");
printf("\nNum1 : %d\tNum2 : %d",num1,num2);

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment