1). What would be printed by the following statements?
#include <iostream.h>
int f(int &i)
{
i = 10;
return(5 * i);
}
int main()
{
int n = 5;
f(n);
cout << n << "\n";
return 0;
}
(a) 5
(b) 10
(c) 50
(d) Compilation/Linkage Error.

2). What would be printed by the following statements?
int y[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
cout << y[1][2];
(a) 5
(b) 6
(c) 2
(d) 4

3). What would be printed by the following program?
#include <iostream.h>
int sub1(int &n)
{
n--;
return n;
}
int main()
{
int m = 10;
for(int j = 0; j < 10; j++)
m -= sub1(j);
cout << m << "\n";
return 0;
}
(a) 0
(b) 1
(c) 9
(d) 10
(e) None of the above.

4). Which operator has the highest precedence?
(a) .
(b) *
(c) []
(d) &

5). What would be printed by the following statements?
double *pt;
double a[3]={1.2, 2.3, 3.4};
pt=&a[1];
pt+=1;
cout<<*pt<<endl;
(a) 1.2
(b) 2.3
(c) 3.3
(d) 3.4
(e) None of the above.

6). What would be printed by the following statements?
int k;
double j;
k = 2;
j = 2.0;
if(k == j)
{
cout << "Okay.";
}
else
cout << "Not okay.";
(a) Okay.Not okay.
(b) Not okay.
(c) Okay.
(d) Nothing will be outputed.

7). Given a program as follows, what would be printed?
#include <iostream.h>
int myfunc(double);
int myfunc(float);
int main()
{
cout << myfunc(3.51) << "\n";
return 0;
}
int myfunc(double n)
{
return n * 2.0;
}
int myfunc(float n)
{
return n * 3.0;
}
(a) 7
(b) 7.02
(c) 10
(d) 10.53
(e) None of the above.

8). Which statement is equivalent to the following statement?
pt->x_center = 10.0;
(a) *pt.x_center = 10.0;
(b) (*pt).x_center = 10.0;
(c) (*pt.)x_center = 10.0;
(d) (pt->)x_center = 10.0;
(e) None of the above.




9). What would be printed by the following statements?
class complex 
{
public:
double re, im;
};
complex x, y;
x.re = 4.0;
x.im = 5.0;
y = x;
x.re = 5.0;
cout << y.re << endl;
(a) 4.0
(b) 4
(c) 5.0
(d) 5
(e) None of the above.

10). What do the following two cout statements print out?
{
int i = 1;
double x = 1.111;
cout << i << " " << x << "\n";
{
int x = 2;
double i = 2.222;
cout << i << " " << x << "\n";
}
}
(a) 
1 1.111
2 2
(b) 
1 1
2.222 2
(c) 
1 1.111
2.222 2

11). What would be printed by the following program?
#include <iostream.h>

int sum(int pt[], int n)
{
int temp = 0;
for (int i = 0; i < n; ++i) 
{
temp += pt[i];
}
return temp;
}
int main()
{
int total;
int pt[5];
for (int i = 0; i < 5; i++)
pt[i] = i;
total = sum(pt, 3);
cout << total << " " << i << endl;
return 0;
}
(a) 3 5
(b) 3 3
(c) 6 5
(d) 10 3

12). Which of the following statements contains a reference declarator?
(a) int *i;
(b) swap(&x, &y);
(c) int x, *pt; pt = &x;
(d) int x, &pt = x;
(e) None of the above

13). What would be printed by the following statements?
double x = !0 * (1 / 3 * 3.0);
cout << x << endl;
(a) 0
(b) 0.0
(c) 1
(d) 1.0
(e) None of the above.

14). Which is an incorrect initialization?
(a) char plant[] = "Tree";
(b) char plant[] = {’T’,’R’,’E’,’E’};
(c) char plant[80] = "Tree";
(d) char plant[] = {’T’,’R’,’E’,’E’,’\0’};
(e) None of the above.

15). What would be printed by the following program?
#include <iostream.h>
double triangle(double base, double height = 10.0);
int main()
{
cout.setf(ios::showpoint);
cout << triangle(10.0) << "\n";
return 0;
}
double triangle(double base, double height)
{
return 0.5*base*height;
}
(a) 50
(b) 50.0
(c) 50.00
(d) 50.0000
(e) Compilation/Linkage error.
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: