1.
(12 points – 2 pts/answer)
What is the exact output from the following program?
Output is:
2.
(6 points – 2 points each)
1
COP 3502 – Exam #1 – Summer 2002
NAME:
June 10, 2002
(100 points)
#include <stdio.h>
int
q1 (int *, int, int *);
int main ( ) {
int a= 4;
int b = 17;
int *c;
c = &b;
a = q1(&a, b, c);
printf(“2. a = %d, b = %d, *c = %d\n”, a, b, *c);
return 0;
}
int q1 (int *x, int y, int *z){
int a = 5;
int *p;
printf(“1. *x = %d, y = %d, *z = %d\n”, *x, y, *z);
p = z;
*p = a + *x;
return (*x + *z + y);
}
1.
*x = 4, y = 17, *z = 17
2.
a = 30, b = 9, *c = 9
READ THIS!
READ THIS!
READ THIS!
No calculators may be used on this exam.
Place your answers in the boxes.
Use other blank areas to shown your work.
Show all of your work on every problem.
KEY
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
For the function shown below, show the value returned by the function for each of the
three function calls (a) – (c).
(a) Call:
q2(425)
Value returned is:
(b) Call:
q2(872)
value returned is:
(c) What is the task implemented by this function?
3.
(15 points – 5 points each)
Answer each of the following questions.
Be sure to show your work.
(a) What is the decimal equivalent to the binary number:
10011101
answer:
(b) What is the binary equivalent to the decimal number: 79
answer:
(c)
Solve for x in this equation :
log
(x1)
1024 = 5
4.
(12 points – 3 points each answer)
2
157
since,
(1
×
2
7
) + (1
×
2
4
) + (1
×
2
3
) + (1
×
2
2
) + (1
×
2
0
)
= 128 + 16 + 8 + 4 + 1
= 157
1001111
since,
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '09
 Computer Science, Decimal, Return statement, printf

Click to edit the document details