C Mock Exam 3
C Mock Exam 3
Q 2 - An array can be passed to the function with call by value mechanism.
A - True B - False
1
Q 10 - (i) ‘ios’ is the base class of ‘istream’
(ii) All the files are classified into only 2 types. (1) Text Files (2) Binary Files.
A - Only (i) is true B - Only (ii) is true C - Both (i) & (ii) are true D - Both (i) & (ii) are false
Q 11 - An exception is __
A - Runtime error B - Compile time error C - Logical error D - None of the above
#include<iostream>
using namespace std;
main() {
const int a = 5;
a++;
cout<<a;
}
A - 5 B - 6 C - Runtime error D - Compile error
#include<iostream>
using namespace std;
main() {
char s[] = "hello", t[] = "hello";
if(s==t)
cout<<"eqaul strings";
}
A - Equal strings B - Unequal strings C - No output D - Compilation error
2
Q 15 - What is the outpout of the following program?
#include<iostream>
using namespace std;
main() {
enum {
india, is = 7, GREAT
};
cout<<india<<" "<<GREAT;
}
A - 0 1 B - 0 2 C - 0 8 D - Compile error
#include<iostream>
using namespace std;
main() {
short unsigned int i = 0;
cout<<i--;
}
A - 0 B - Compile error C - 65535 D - 32767
#include<iostream>
using namespace std;
main() {
int x = 5;
if(x==5) {
if(x==5) break;
cout<<"Hello";
}
cout<<”Hi”;
}
A - Compile error B - Hi C - HelloHi D - Hello
3
Q 18 - What is the output of the following program?
#include<iostream>
using namespace std;
void f() {
static int i;
++i;
cout<<i<<" ";
}
main() {
f();
f();
f();
}
A - 1 1 1 B - 0 0 0 C - 3 2 1 D - 1 2 3
#include<iostream>
using namespace std;
void f() {
cout<<"Hello"<<endl;
}
main() {
}
A - No output
B - Error, as the function is not called.
C - Error, as the function is defined without its declaration
D - Error, as the main() function is left empty
4
Q 20 - What is the output of the following program?
#include <iostream>
using namespace std;
int main () {
// local variable declaration:
int x = 1;
switch(x) {
case 1 :
cout << "Hi!" << endl;
break;
default :
cout << "Hello!" << endl;
}
}
A - Hello B - Hi C - HelloHi D - Compile error
5
Q 23 - What is the output of the following program?
#include<iostream>
using namespace std;
main() {
int r, x = 2;
float y = 5;
r = y%x;
cout<<r;
}
A - 1 B - 0 C - 2 D - Compile error
#include<iostream>
using namespace std;
main() {
union abc {
char a, b, c, d, e, f, g, h;
int i;
};
cout<<sizeof(abc);
}
A - 1 B - 2 C - 4 D - 8
6
Question Number Answer Key
7
1 C
2 B
3 D
4 B
5 B
6 A
7 B
8 C
9 B
10 C
11 A
12 A
13 D
14 C
15 C
16 A
17 A
18 D
19 A
20 B
21 B
22 A
23 D
24 C
25 D