Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 334 Bytes

Pass Addresses to Functions.md

File metadata and controls

22 lines (18 loc) · 334 Bytes

#include <stdio.h> void swap(int *n1, int *n2);

int main() { int num1 = 5, num2 = 10;

// address of num1 and num2 is passed
swap( &num1, &num2);

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

}

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