This Program swaps 2 numbers using pointers and functions . This is a part of Mumbai University MCA Colleges C Program MCA sem 1
#include<stdio.h>
#include<conio.h>
void swap(int*, int *);
void main()
{
int a,b;
clrscr();
printf("Enter 2 nos\n");
scanf("%d %d",&a, &b);
printf("\nBefore swapping: %d %d",a,b);
swap(&a, &b);
printf("\n After swaping: %d %d",a,b);
getch();
}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
No comments:
Post a Comment