// 24T2 COMP1511 Week 5 Lecture 2 // Tammy Zhong #include void square_num(int *n); // CHANGED void swap(int n1, int n2); int main(void) { int num1 = 7; // printf("Num1 before square_num: %d\n", num1); // square_num(&num1); // CHANGED // printf("Num1 after square_num: %d\n", num1); // should print 49 int num2 = 8; printf("Before swap: num1 = %d, num2 = %d\n", num1, num2); swap(num1, num2); // it's not we're giving the variable to the other function // it's actually we are copying over the value from these two variables into // n1 and n2 in the function printf("After swap: num1 = %d, num2 = %d\n", num1, num2); return 0; } // // square the value of n // void square_num(int *n) { // CHANGED n is a copy of what is in num1 in the main function // *n = *n * *n; //? // } // swap the values in the two given variables around void swap(int num1, int num2) { // TODO int temp = num1; num1 = num2; num2 = temp; }