CPP

CPP

Veriable Types has 57 Questions
The size of an object or a type can be determined using which operator?

malloc
sizeof
malloc
calloc
It is guaranteed that a ____ has atleast 8bits and a ____ has atleast 16 bits.

int, float
char, int
bool, char
char, short
Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is _____

char, 1
int, 1
float, 8
char, 4
Identify the incorrect option

1 <= sizeof(bool) <= sizeof(long)
sizeof(float) <= sizeof(double) <= sizeof(long double)
sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
sizeof(N) = sizeof(signed N) = sizeof(unsigned N) [expand title="View Answer"]
Which of the following will not return a value?

null
void
empty
free
____ have the return type void?

all functions
constructors
destructors
none of the mentioned
Identify the incorrect option?

enumerators are constants
enumerators are user defined types
enumerators are same as macros
enumerator values start from 0 by default
In which type does the enumerators are stored by the compiler?

string
integer
float
none of the mentioned
To which of these enumerators can be assigned?

integer
negative
enumerator
all of the mentioned
What will happen when defining the enumerated type?

it will not allocate memory
it will allocate memory
it will not allocate memory to its variables
none of the mentioned
Which variable does equals in size with enum variable?

int variable
float variable
string variable
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     enum  cat {
  4.         temp = 7
  5.     };
  6.     int main()
  7.     {
  8.         int age = 14;
  9.         age /= temp;
  10.         cout << "If you were cat, you would be " << age << endl;
  11.         return 0;
  12.     }

If you were cat, you would be 5
If you were cat, you would be 2
If you were cat, you would be 7
none of the mentioned
What is output of the this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int i;
  6.         enum month {
  7.             JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
  8.         };
  9.         for (i = MAR; i <= NOV; i++)
  10.             cout << i;
  11.         return 0;
  12.     }

01234567891011
123456789101112
34567891011
123456789
What is the size of wchar_t in C++?

2
4
2 or 4
based on the number of bits in the system
Pick the odd one out

array type
character type
boolean type
integer type
Which datatype is used to represent the absence of parameters?

int
short
void
float
What does a escape code represent?

alert
backslash
tab
form feed
Which type is best suited to represent the logical values?

integer
boolean
character
all of the mentioned
Identify the user-defined types from the following?

enumeration
classes
both a and b
int

Which of the following statements are true?

int f(float)


f is a function taking an argument of type int and retruning a floating point number
f is a function taking an argument of type float and returning a integer.
f is a function of type float
none of the mentioned
The value 132.54 can represented using which data type?

double
void
int
bool
When a language has the capability to produce new data type mean, it can be called as

overloaded
extensible
encapsulated
reprehensible
Pick the odd one out.

integer, character, boolean, floating
enumeration, classes
integer, enum, void
arrays, pointer, classes
Is bool a fundamental datatype in C++?

Yes
No, it is a typedef of unsigned char
No, it is an enum of {false,true}
No, it is expanded from macros
Find the odd one out.

std::vector<int>
std::vector<short>
std::vector<long>
std::vector<bool>
What is the value of the bool?
  1. bool is_int(789.54)

True
False
1
none of the mentioned
What happens when a null pointer is converted into bool?

An error is flagged
bool value evaluates to true
bool value evaluates to false
the statement is ignored
Which of the following statements are false?

bool can have two values and can be used to express logical expressions.
bool cannot be used as the type of the result of the function.
bool can be converted into integers implicitly
a bool value can be used in arithemetic expressions.
For what values of the expression is an if-statement block not executed?

0 and all negative values
0 and -1
0
0, all negative values, all positive values except 1
Which of the two operators ++ and -- work for the bool datatype in C++?

None
++
--
Both
What is the output of the following program?
  1.     #include 
  2.     using namespace std;
  3.     int f(int p, int q)
  4.     {
  5.         if (p > q)
  6.             return p;
  7.         else
  8.             return q;
  9.     }
  10.     main()
  11.     {
  12.         int a = 5, b = 10;
  13.         int k;
  14.         bool x = true;
  15.         bool y = f(a, b);
  16.         k =((a * b) + (x + y));
  17.         cout << k;
  18.     }

55
62
52
none of the mentioned
Evaluate the following (false && true) || false || true

0
1
false
none of the mentioned
How many characters are specified in the ASCII scheme?

64
128
256
none of the mentioned
Select the right option. Given the variables p, q are of char type and r, s, t are of int type 1. t = (r * s) / (r + s); 2. t = (p * q) / (r + s);

1 is true but 2 is false
1 is false and 2 is true
both 1 and 2 are true
both 1 and 2 are false
Which of the following belongs to the set of character types?

char
wchar_t
only a
both a and b
What will be the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         char c = 74;
  6.         cout << c;
  7.         return 0;
  8.     }

A
N
J
I
How do we represent a wide character of the form wchar_t?

L'a'
l'a'
L[a]
la
What is the output of this program?
  1.     #include 
  2.     int main()
  3.     {
  4.         char a = '\012';
  5. ?
  6.         printf("%d", a);
  7.         return 0;
  8.     }

Compiler error
12
10
Empty
In C++, what is the sign of character data type by default?

Signed
Unsigned
Implementation dependent
None of these
Is the size of character literals different in C and C++?

Implementation defined
Can't say
Yes, they are different
No, they are not different
Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?

4
1
Implementation dependent
Machine dependent
What constant defined in header returns the number of bits in a char?

CHAR_SIZE
SIZE_CHAR
BIT_CHAR
CHAR_BIT
The size_t integer type in C++ is?

Unsigned integer of at least 64 bits
Signed integer of at least 16 bits
Unsigned integer of at least 16 bits
Signed integer of at least 64 bits
What is the output of the following program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.     	int x = -1;
  6.         unsigned int y = 2;
  7. ?
  8.         if(x > y) {
  9.         	cout << "x is greater";
  10.     	} else {
  11.     		cout << "y is greater";
  12.     	}
  13.     }

x is greater
y is greater
Implementation defined
Arbitrary
Which of these expressions will return true if the input integer v is a power of two?

(v | (v + 1)) == 0;
(~v & (v ? 1)) == 0;
(v | (v ? 1)) == 0;
(v & (v ? 1)) == 0;
What is the value of the following 8-bit integer after all statements are executed? int x = 1; x = x << 7; x = x >>7;

1
-1
127
Implementation defined
Which of these expressions will make the rightmost set bit zero in an input integer x?

x = x | (x-1)
x = x & (x-1)
x = x | (x+1)
x = x & (x+1)
Which of these expressions will isolate the rightmost set bit?

x = x & (~x)
x = x ^ (~x)
x = x & (-x)
x = x ^ (-x)
0946, 786427373824, 'x' and 0X2f are _____, _____, ____ and _____ literals respectively

decimal, character,octal, hexadecimal
octal, hexadecimal, character, decimal
hexadecimal, octal, decimal, character
octal, decimal, character, hexadecimal
What will be the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int a = 8;
  6.         cout << "ANDing integer 'a' with 'true' :" << a && true;
  7.         return 0;
  8.     }

ANDing integer 'a' with 'true' :8
ANDing integer 'a' with 'true' :0
ANDing integer 'a' with 'true' :1
None of the mentioned
What will be output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int i = 3;
  6.         int l = i / -2;
  7.         int k = i % -2;
  8.         cout << l << k;
  9.         return 0;
  10.     }

compile time error
-1 1
1 -1
implementation defined
What will be output of this function?
  1.     int main()
  2.     {
  3.         register int i = 1;
  4.         int *ptr = &i;
  5.         cout << *ptr;
  6. 	return 0;
  7.     }

0
1
Compiler error may be possible
Runtime error may be possible
Which of the following is not one of the sizes of the floating point types?

short float
float
long double
double
Which of the following is a valid floating point literal?

f287.333
F287.333
287.e2
287.3.e2
What is the range of the floating point numbers?

-3.4E+38 to +3.4E+38
-3.4E+38 to +3.4E+34
-3.4E+38 to +3.4E+36
-3.4E+38 to +3.4E+32
Which of three sizes of floating point types should be used when extended precision is required?

float
double
long double
extended float
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         float num1 = 1.1;
  6.         double num2 = 1.1;
  7.         if (num1 == num2)
  8.            cout << "stanford";
  9.         else
  10.            cout << "harvard";
  11.         return 0;
  12.     }

harvard
stanford
compile time error
runtime error