C program to swap values of two variables using function (call by reference).

#include<stdio.h>
#include<conio.h>
void main(){
int a,b;
void swap(int*,int*);
clrscr();
printf("Enter two integer numbers\n");
scanf("%d%d",&a,&b);
printf("Before swapping A=%d and B=%d\n",a,b);
swap(&a,&b);
printf("After swapping A=%d and B=%d\n",a,b);
getch();
}
void swap(int *x,int *y){
int z;
z=*x;
*x=*y;
*y=z;
return;
}

Comments

Popular posts from this blog

C Language Topics in Hindi and English

C language IMP Questions for BSc/BA/BCom/BCA/BE/BTech/MSc/MCA (CS/IT) I year students