Question: By modifying the C code given below, In the main function declare two character variables then print them and their addresses. Now use these variables
By modifying the C code given below, In the main function declare two character variables then print them and their addresses. Now use these variables as parameters and apply the bad_swap and print the results(value of variables and addresses). Do the same with the good_swap and print the results.
code:
#includevoid bad_swap(char, char); int main() { char a,b; printf("Enter two characters : "); scanf("%c %c", &a, &b); printf(" "); bad_swap(a, b); return 0; } void bad_swap(char a, char b) { char temp = b; b = a; a = temp; }
OUTPUT would be like :

After bad swap (without pointers): var_1 = A, address = 0060FEEB var_2 = B, address = 0060FEEA After good swap (with pointers): var_1 = B, address = 0060FEEB var_2 = A, address = 0060FEEA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
