How to pass addresses function in C

1 Answer

0 votes
#include <stdio.h>

void swap(int* n1, int* n2) {
    int temp;
    temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

int main()
{
    int num1 = 75, num2 = 3;

    swap(&num1, &num2);

    printf("num1 = %d\n", num1);
    printf("num2 = %d", num2);
    
    return 0;
}




/*
run:
     
num1 = 3
num2 = 75
     
*/

 



answered Nov 28, 2021 by avibootz
...