48. Pointer- Swap Value

Back To All Submissions
Previous Submission
Next Submission

Code

//swap using pointers 

#include<stdio.h>
void swap(int *a,int *b){
    int temp= 0;
    temp = *a;
    *a = *b;
    *b = temp;

}

int main(){

    int a,b;
    scanf("%d %d",&a,&b);
    swap(&a,&b);
    printf("a = %d b = %d", a,b);
    return 0;
}

    

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote