c icon indicating copy to clipboard operation
c copied to clipboard

Swap

Open bca072024 opened this issue 1 year ago • 1 comments

Write a c program to swap the number using pointer #include<stdio.h> #include<conio.h> void main() { int x,y; void swap(int*,int*); printf("\n Enter two number"); scanf("%d%d",&x,&y); printf("\n Before swapping x=%d and y=%d",x,y); swap(&x,&y); printf("\n After swapping x=%d and y=%d",x,y); } void swap(int *a,int *b) { int temp; temp=*a; *a=*b; *b=temp; }

bca072024 avatar Jul 12 '24 08:07 bca072024

//Write a c program to swap the number using pointer #include<stdio.h> #include<conio.h> int main() { int x,y; void swap(int*,int*); printf("Enter your 1st number : "); scanf("%d",&x); printf("Enter your 2nd number : "); scanf("%d",&y); printf("\nBefore swapping x = %d and y = %d",x,y); swap(&x,&y); printf("\nAfter swapping x = %d and y = %d",x,y); } void swap(int *a,int *b) { int temp; temp=*a; *a=*b; *b=temp; }

Manishmine avatar Nov 24 '24 14:11 Manishmine