1. Choose the correct option.
extern int i;
int i;
a) both 1 and 2 declare i
b) 1 declares the variable i and 2 defines i
c) 1 declares and defines i, 2 declares i
d) 1 declares i,2 declares and defines i
2. Pick the right option
Statement 1:A definition is also a declaration.
Statement 2:An identifier can be declared just once.
a) Statement 1 is true, Statement 2 is false.
b) Statement 2 is true, Statement 1 is false.
c) Both are false.
d) Both are true.
3. Which of the given statements are false.
1. extern int func;
2. extern int func2(int,int);
3. int func2(int,int);
4. extern class foo;
a) 3 and 4 only
b) 2 and 3 only
c) only 4
d) 2, 3 and 4
4. Pick the right option
Statement 1:Global values are not initialized by the stream.
Statement 2:Local values are implicitly initialised to 0.
a) Statement 1 is true, Statement 2 is false.
b) Statement 2 is true, Statement 1 is false.
c) Both are false.
d) Both are true.
5. What is the output of this program?
a) 2035655065
b) 2035655035
c) 2035635065
d) none of the mentioned
6. Can two functions declare variables(non static) with the same name.
a) No
b) Yes
c) Yes, but not a very efficient way to write programs.
d) No, it gives a runtime error.
7. What is the output of this program?
a) 234
b) 111
c) 123
d) 235
8. What is the output of this program?
a) 0123456789
b) 123456789
c) 0
d) error
9. Identify the incorrect statements.
int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&var = 40; //statement 3
a) Statement 1 and 2 are wrong
b) Statement 2 and 3 are wrong
c) Statement 1 and 3 are wrong
d) All the three are wrong
10. Identify the type of the variables.
typedef char* CHAR;
CHAR p,q;
a) char*
b) char
c) CHAR
d) unknown
extern int i;
int i;
a) both 1 and 2 declare i
b) 1 declares the variable i and 2 defines i
c) 1 declares and defines i, 2 declares i
d) 1 declares i,2 declares and defines i
Answer:d
2. Pick the right option
Statement 1:A definition is also a declaration.
Statement 2:An identifier can be declared just once.
a) Statement 1 is true, Statement 2 is false.
b) Statement 2 is true, Statement 1 is false.
c) Both are false.
d) Both are true.
Answer: b
3. Which of the given statements are false.
1. extern int func;
2. extern int func2(int,int);
3. int func2(int,int);
4. extern class foo;
a) 3 and 4 only
b) 2 and 3 only
c) only 4
d) 2, 3 and 4
Answer:c
4. Pick the right option
Statement 1:Global values are not initialized by the stream.
Statement 2:Local values are implicitly initialised to 0.
a) Statement 1 is true, Statement 2 is false.
b) Statement 2 is true, Statement 1 is false.
c) Both are false.
d) Both are true.
Answer:c
5. What is the output of this program?
#include <iostream>
using namespace std;
int g = 100;
int main()
{
int a;
{
int b;
b = 20;
a = 35;
g = 65;
cout << b << a << g;
}
a = 50;
cout << a << g;
return 0;
}
b) 2035655035
c) 2035635065
d) none of the mentioned
Answer:a
6. Can two functions declare variables(non static) with the same name.
a) No
b) Yes
c) Yes, but not a very efficient way to write programs.
d) No, it gives a runtime error.
Answer:c
7. What is the output of this program?
#include <iostream>
using namespace std;
void addprint()
{
static int s = 1;
s++;
cout << s;
}
int main()
{
addprint();
addprint();
addprint();
return 0;
}
b) 111
c) 123
d) 235
Answer:a
8. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int a = 10;
if (a < 10) {
for (i = 0; i < 10; i++)
cout << i;
}
else {
cout << i;
}
return 0;
}
b) 123456789
c) 0
d) error
Answer:d
9. Identify the incorrect statements.
int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&var = 40; //statement 3
a) Statement 1 and 2 are wrong
b) Statement 2 and 3 are wrong
c) Statement 1 and 3 are wrong
d) All the three are wrong
Answer:c
10. Identify the type of the variables.
typedef char* CHAR;
CHAR p,q;
a) char*
b) char
c) CHAR
d) unknown
Answer:a