48. Pointer- Swap Value

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>
void swap(int *a, int *b);
int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    swap(&a, &b);
    
    return 0;
}
void swap(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
    printf("a = %d b = %d", *a, *b);
    
}

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote