Question: 4. (12 points) The following C main program and subprogram are given. Answer the questions based on this program main() { int a,b,c; scanf(%d,a) scanf(%d,b)
4. (12 points) The following C main program and subprogram are given. Answer the questions based on this program main() { int a,b,c; scanf("%d",a) scanf("%d",b) printf("%d %d ",a,b); swap(a, b); printf("%d %d ", a,b); } void swap(int px, int py) { int temp; temp =px; px - py; py = temp; } a. What is the main program supposed to do? b. Correct the errors in the scanf statements? c. What is the subprogram supposed to do? d. Suppose a is read as 2 and b is read as 3. What would be the result of the first printf statement? e. What would be the result of the second printf statement? f. If you want the second printf statement to give the intended result, indicate all corrections that should be done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
