What will be the output of the following C++ code?
#include <iostream>
using namespace std;
enum cat
{
temp = 7
};
int main()
{
int age = 14;
age /= temp;
cout << "If you were cat, you would be " << age << endl;
return 0;
}A. If you were cat, you would be 5
B. If you were cat, you would be 2
C. If you were cat, you would be 7
D. If you were cat, you would be 9
Select an option to see the answer and solution.
For what values of the expression is an if-statement block not executed?
A. 0 and all negative values
B. 0 and -1
C. 0
D. 0, all negative values, all positive values except 1
Select an option to see the answer and solution.
Identify the incorrect statements.
int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&&var = 40; //statement 3A. Statement 1 and 2 are wrong
B. Statement 2 and 3 are wrong
C. Statement 1 and 3 are wrong
D. Statement 1, 2 and 3 are wrong
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
Is the size of character literals different in C and C++?
A. Implementation defined
B. Can't say
C. Yes, they are different
D. No, they are not different
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
void a = 10, b = 10;
int c;
c = a + b;
cout << c;
return 0;
}A. 20
B. compile time error
C. runtime error
D. 40
Select an option to see the answer and solution.
Which is correct with respect to the size of the data types?
A. char > int < float
B. int < char > float
C. char < int < float
D. char < int < double
Select an option to see the answer and solution.
Which of the following is not one of the sizes of the floating point types?
A. short float
B. float
C. long double
D. double
Select an option to see the answer and solution.
. . . . . . . . have the return type void.
A. all functions
B. constructors
C. destructors
D. none of the mentioned
Select an option to see the answer and solution.
Which of these expressions will make the rightmost set bit zero in an input integer x?
A. x = x | (x-1)
B. x = x & (x-1)
C. x = x | (x+1)
D. x = x & (x+2)
Select an option to see the answer and solution.
Which of the following is a valid floating-point literal?
A. f287.333
B. F287.333
C. 287.e2
D. 287.3.e2
Select an option to see the answer and solution.
Identify the type of variables.
typedef char* CHAR;
CHAR p,q;A. char*
B. char
C. CHAR
D. unknown
Select an option to see the answer and solution.
Given the variables p, q are of char type and r, s, t are of int type. Select the right statement?
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);A. 1 is true but 2 is false
B. 1 is false and 2 is true
C. both 1 and 2 are true
D. both 1 and 2 are false
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
float f1 = 0.5;
double f2 = 0.5;
if (f1 == 0.5f)
cout << "equal";
else
cout << "not equal";
return 0;
}A. equal
B. not equal
C. compile time error
D. runtime error
Select an option to see the answer and solution.
To which of these enumerators can be assigned?
A. integer
B. negative
C. enumerator
D. all of the mentioned
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#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;
}A. 2035655065
B. 2035655035
C. 2035635065
D. 2035645065
Select an option to see the answer and solution.
Identify the user-defined types from the following?
A. enumeration
B. classes
C. both enumeration and classes
D. int
Select an option to see the answer and solution.
Identify the incorrect option.
A. enumerators are constants
B. enumerators are user-defined types
C. enumerators are same as macros
D. enumerator values start from 0 by default
Select an option to see the answer and solution.