C++ Language | 10 Minute‐Test 3


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Which datatype is used to represent the absence of parameters ?

A.
int
B.
short
C.
void
D.
float

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

void will not return anything.



2.

What is the value of the bool ?

  1. bool is_int (789.54 )

     

A.
true
B.
false
C.
1
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The given number is a double not an integer, so the function returns 0 which
is boolean false.



3.

Which of the following belongs to the set of character types ?

A.
char
B.
wchar_t
C.
only a
D.
both a and b

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

wchar_t and char is used to represent wide character and character.



4.

#include <iostream>

using namespace std;

int main()

{

int i = 3;

int l = i / -2;

int k = i % -2;

cout << l << k;

return 0;

}

 

A.
Compile time error
B.
-1 1
C.
1 -1
D.
implementation defined

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Sign of result of mod operation on negative numbers is sign of the dividend.


5.

The correct statement for a function that takes pointer to a float, a pointer to a pointer
to a char and returns a pointer to a pointer to a integer is

A.
int **fun(float**, char**)
B.
int **fun(float**, char**)
C.
int ***fun(float*, char**)
D.
int ***fun(*float, **char)

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None


6.

What is the output of this program ?

  1. #include <iostream>
  2. using namespace std;
  3. void addprint ()
  4. {
  5. static int s = 1 ;
  6. s++ ;
  7. cout << s;
  8. }
  9. int main ()
  10. {
  11. addprint() ;
  12. addprint() ;
  13. addprint() ;
  14. return 0 ;
  15. }

A.
234
B.
111
C.
123
D.
235

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

The variable that is declared as static has a file scope.
Output:
$ g++ dec2.cpp
$ a.out
234


7.

What is the output of this program ?

#include

using namespace std;

int operate (int a, int b )

{

return ( a * b );

}

float operate (float a, float b )

{

return ( a / b );

}

int main ()

{

int x = 5, y = 2 ;

float n = 0 , m = 2.0 ;

cout << operate ( x, y );

cout << operate ( n, m );

return 0 ;

}

 

A.
119
B.
102.5
C.
123.4
D.
none of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

In this program, We are overloading the function and getting the output as 10 and 2.5 by division and multiplication.
Output:
$ g++ call3.cpp
$ a.out
102.5

8.

What is the use of functor ?

A.
It makes the object “callable” like a function.
B.
It makes the class “callable” like a function.
C.
It makes the attribute “callable” like a function.
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None



9.

What is the output of this program ?

  1. #include <iostream>
  2.     #include <string.h>
  3.     using namespace std ;
  4.     int main()
  5.     {
  6.         struct student {
  7.             int num;
  8.             char name[ 25 ];
  9.         } ;
  10.         student stu;
  11.         stu.num = 123 ;
  12.         strcpy (stu. name , "John" ) ;
  13.         cout << stu. num << endl ;
  14.         cout << stu. name << endl ;
  15.         return 0;
  16.     }

A.
123
john
B.
john
john
C.
compile time error
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

We are coping the value john to the name and then we are printing the values that are in the program.
Output:
$ g++ stu.cpp
$ a.out
123
john

10.

Pick out the correct statement.

A.
Increment operator ++ adds 1 to its operand
B.
Increment operator ++ adds 2 to its operand
C.
Decrement operator ++ subtracts 1 to its operand
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

none

Submit your test now to view the Results and Statistics with answer explanation.