Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
1) The following program compiles and runs without errors. What will get printed? #include void swap1(int a, int b){ int temp = a; a =
1) The following program compiles and runs without errors. What will get printed? #include void swap1(int a, int b){ int temp = a; a = b; b = temp; } void swap2(int a[], int b[]){ int temp = a[0]; a[0] = b[0]; b[0] = temp; } void swap3(int *a, int *b){ int temp = *a; *a = *b; *b = temp; void main(void) { } int a[2] = {2, 6); int b[2] = {0, 4}; swap1(a[0], a[1]); printf("%d, %d\ ", a[0], a[1]); Write your answer here. Solution: //2, 6 //0, 6, 2, 4 //4, 2 swap2(a, b); printf("%d, %d, %d, %d \ ", a[0], a[1], b[0], b[1]); swap3(&b[0], &b[1]); printf("%d, %d\ ", b[0], b[1]); (NO CHANGE) (a - {0, 6), b = {2,4}) (b = {4, 2})
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started