Problem 50. C Program to interchange two values using pointers.
#include<stdio.h>
#include<conio.h>
void interchange(int *x,int *y);
main( )
{
int a,b;
clrscr( );
printf(“enter values of a and b”);
scanf(“%d%d”,&a,&b);
interchange(&a,&b);
}
void interchange(x,y)
int *x,*y;
{
int t;
t=*x;
*x=*y;
*y=t;
printf(“%d=x, %d=y”,*x,*y);
getch( );
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignment#include<stdio.h>
#include<conio.h>
void interchange(int *x,int *y);
main( )
{
int a,b;
clrscr( );
printf(“enter values of a and b”);
scanf(“%d%d”,&a,&b);
interchange(&a,&b);
}
void interchange(x,y)
int *x,*y;
{
int t;
t=*x;
*x=*y;
*y=t;
printf(“%d=x, %d=y”,*x,*y);
getch( );
}
C compiler: gcc 4.1.2