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:

#include  void 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 :

By modifying the C code given below, In the main function declare

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!