48. Pointer- Swap Value

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>
#include <stdint.h>


void swap (int *a, int *b){
    int 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