Name______________________________________________________________
1. (50%)
Consider the following program:
void
GI (int& x, int& y) {
x = 3;
y = x + 2;
}
int
C (int x, int b, int& z) {
int j = 0;
z = 0;
x = 1;
while (j < b) {
j+=2;
z += 1;
}
return j;
}
void
main () {
int x, y, z;
GI (x, y);
cout << C (x, y, z) << endl;
if (z >= 2) {
cout << x
<<"," << y << "," <<z;
}
}
output:
6
3,5,3
![]()
float Func (int n) {
float
sum = 0.0;
for (int j = 1; j <=
n; j++) {
sum +=
(j/pow(2.0, j-1));
}
return sum;
}