Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The first three questions concern the output of the following C program: #includ

ID: 3681356 • Letter: T

Question

The first three questions concern the output of the following C
program:
#include <stdio.h>
int f(int a, int b);
int main() {
int a = 2, b = 7;
b = f(b+a, b-a);
printf("a = %d ", a);
printf("b = %d ", b);
return 0;
}
int f(int a, int b) {
a += 3;
b = 2*a - b + 5;
printf("a = %d, b = %d ", a , b);
return a+b;
}
1) What is the output of the first line of the program?
A) a = 3, b = 11 B) a = 10, b = 23 C) a = 12, b = 24
D) a = 7, b = 17 E) None of the Above

2) What is the output of the second line of the program?
A) a = 2 B) a = 3 C) a = 7 D) a = 12
E) None of the Above

3) What is the output of the third line of the program?
A) b = 7 B) b = 23 C) b = 24 D) b = 36
E) None of the Above

4) Assume that x is an integer variable. Which of the following
represents the memory address where x is stored?
A) x B) &x C) *x D) 2*x E) None of the Above

5) Which of the following opens the file “a.txt” to write to?
A) FILE* ifp=open(“a.txt”); B) FILE* ifp=fopen(“a.txt”)
C) FILE* ifp=open(“a.txt”,”w”); D) FILE* ifp=fopen(“a.txt”,”r”);
E) None of the Above

Questions 6 - 8 concern the output of the following C program:
#include <stdio.h>
int g(int *a, int *b);
int main() {
int a = 2, b = 7;
b = g(&b, &a);
printf("a = %d ", a);
printf("b = %d ", b);
return 0;
}
int g(int *a, int *b) {
(*a) = (*a) + 3;
(*b) = 2*(*a) - (*b) + 5;
printf("a = %d, b = %d ", *a , *b);
return (*a)+(*b);
}
6) What is the output of the first line of the program?
A) a = 3, b = 11 B) a = 10, b = 23 C) a = 12, b = 24
D) a = 7, b = 17 E) None of the Above

7) What is the output of the second line of the program?
A) a = 2 B) a = 3 C) a = 7 D) a = 12
E) None of the Above

8) What is the output of the third line of the program?
A) b = 7 B) b = 23 C) b = 33 D) b = 36
E) None of the Above

9) Which of the following is potentially a valid formal parameter to
some function?
A) 3 B) 17 C) x D) x + y E) None of the Above

10) Which of the following is true of arrays in C?
A) Their names must start with a letter.
B) They can have no more than 10000 slots.
C) They must store integers or characters.
D) They are defined using a for loop.
E) None of the Above

Questions 11 - 14 concern the output of the following C program:
#include <stdio.h>
void mixarray(int array[], int length);
int main() {
int vals[] = {3, 8, 2, 7};
mixarray(vals, 4);
int i;
for (i=0; i<4; i++)
printf("vals[%d] = %d ", i, vals[i]);
return 0;
}
void mixarray(int array[], int length) {
int i;
for (i=1; i<length; i++)
array[i] += array[i-1];
}
11) What is the output of the first line of the program?
A) vals[0] = 0 B) vals[0] = 3 C) vals[0] = 8 D) vals[0] = 11
E) None of the Above

12) What is the output of the second line of the program?
A) vals[1] = 8 B) vals[1] = 11 C) vals[1] = 13 D) vals[1] = 20
E) None of the Above

13) What is the output of the third line of the program?
A) vals[2] = 2 B) vals[2] = 10 C) vals[2] = 13 D) vals[2] = 20
E) None of the Above

14) What is the output of the fourth line of the program?
A) vals[3] = 7 B) vals[3] = 9 C) vals[3] = 13 D) vals[3] = 20
E) None of the Above

Explanation / Answer

1. C

2. A

3. D

4. B

5. C

6. C

7. A

8. D

9. C

10. A

11. B

12. B

13. C

14. D

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote