0

programming languages Online Quiz - 276

Description: programming languages Online Quiz - 276
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

C++

  1. unsigned int

  2. char

  3. Float

  4. None of the Above


Correct Option: C
  1. public

  2. protected

  3. guarded

  4. None of the Above


Correct Option: C

C++

  1. &&

  2. ||

  3. !

  4. None of the Above


Correct Option: C

C++

  1. True

  2. False

  3. It depends on the variable type

  4. None of the Above


Correct Option: C
  1. sin()

  2. kbhit()

  3. tmpnam()

  4. None of the Above


Correct Option: B

C++

  1. char *a=new char[20];

  2. char a=new char[20];

  3. char a=new char(20.0);

  4. None of the Above


Correct Option: A

C++

  1. class aClass{public:int x;};

  2. /* A comment */

  3. char x=12;

  4. None of the Above


Correct Option: A
  1. int main()

  2. int main(int argc, char *argv[])

  3. They both work

  4. None of the Above


Correct Option: C

C++

  1. True

  2. False

  3. Invalid Statement

  4. None of the Above


Correct Option: A

C++

  1. The snippet is illegal

  2. It loops forever

  3. It is ignored by compiler, but it is not illegal

  4. None of the Above


Correct Option: B

C++

  1. Constructor

  2. Destructor

  3. Constitutor

  4. None of the Above


Correct Option: A

What does 7/9*9 equal (in C and C++)?

  1. 1

  2. 0.08642

  3. 0

  4. None of the Above


Correct Option: C

AI Explanation

To evaluate the expression 7/9 * 9 in C and C++, we need to consider the data types involved.

By default, when dividing two integers in C and C++, the result will be an integer, which means the decimal part will be truncated.

Let's evaluate the expression step by step:

7/9 = 0 (since both 7 and 9 are integers, the result will be an integer and the decimal part is truncated)

0 * 9 = 0 (0 multiplied by any number is 0)

Therefore, the result of the expression 7/9 * 9 in C and C++ is 0.

Hence, the correct answer is option C.

What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<

  1. 1

  2. 0

  3. Code cannot compile

  4. None of the Above


Correct Option: B

AI Explanation

To determine the output of the given code, let's analyze the code step by step:

  1. The function int v() is defined, which returns an integer value.
  2. Inside the function v(), a variable m is declared and initialized to 0.
  3. The statement return m++; is used to return the value of m and then increment it by 1. However, the postfix increment operator (++) returns the original value of m before incrementing it.
  4. The main() function is defined.
  5. The output statement cout &lt;&lt; v(); is used to call the v() function and print its return value.

Now, let's go through each option to determine the correct output:

Option A) 1 - This option is incorrect because the postfix increment operator (m++) returns the original value of m before incrementing it. Therefore, the value returned by v() will be 0.

Option B) 0 - This option is correct because the return statement return m++; returns the initial value of m, which is 0.

Option C) Code cannot compile - This option is incorrect because the code provided is syntactically correct and will compile without any errors.

Option D) None of the Above - This option is incorrect because the correct answer is Option B) 0.

Therefore, the correct answer is Option B) 0.

Which of the following is evaluated first:

  1. &&

  2. ||

  3. !

  4. None of the Above


Correct Option: C

Which is not an ANSI C++ function?

  1. sin()

  2. kbhit()

  3. tmpnam()

  4. None of the Above


Correct Option: B

True or false: If you continuously increment a variable, it will become negative?

  1. True

  2. False

  3. It depends on the variable type

  4. None of the Above


Correct Option: C

What character terminates all strings composed of character arrays?

  1. \0

  2. .

  3. \END

  4. None of the Above


Correct Option: A

Which of the following functions initalizes the variables contained in a class:

  1. Constructor

  2. Destructor

  3. Constitutor

  4. None of the Above


Correct Option: A

Is C++ case sensitive?

  1. No

  2. Case sensitivity is compiler-determined

  3. Yes

  4. None of the Above


Correct Option: C

Which datatype can store decimal numbers?

  1. unsigned int

  2. char

  3. Float

  4. None of the Above


Correct Option: C
- Hide questions