(C++) CPP Programs - 28

Friday, December 14, 2007

28. Write a C program to read two integers M and N and to swap their values. Use a user defined functions for swapping. Output the values of M and N before and after swapping with suitable message.

/* Swapping*/

#include
#include

void main()
{
int m,n;
clrscr();

printf("Enter the values for m,n\n\a");
scanf("%d%d",&m,&n);

swap(&m,&n);

printf("Function after swapping\n\a");
printf("\n m=%d n=%d\n",m,n);

getch();
}

swap(int *m,int *n)
{
int temp;
temp=*m;
*m=*n;
*n=temp;
}

0 comments:

Post a Comment

Chitika

About This Blog

Followers

Blog Archive

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP