Sail E0 Webinar

MCQs

Total Questions : 9
Question 1.

How to declare a wide character in string literal?


  1.    L prefix
  2.    l prefix
  3.    W prefix
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> L prefix

It can turn this as wide character instead of narrow characters.


Question 2.

The difference between x and 'x' is


  1.    The first one refers to a variable whose identifier is x and the second one refers to the character constant x
  2.    The first one is a character constant x and second one is the string literal x
  3.    Both are same
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> The first one refers to a variable whose identifier is x and the second one refers to the character constant x

None.


Question 3.

Regarding following statement which of the statements is true?
 const int a = 100;


  1.    Declares a variable a with 100 as its initial value
  2.    Declares a construction a with 100 as its initial value
  3.    Declares a constant a whose value will be 100
  4.    Constructs an integer type variable with a as identifier and 100 as value
 Discuss Question
Answer: Option C. -> Declares a constant a whose value will be 100

Because the const is used to declare non-changable values only.


Question 4.

Which of the following statement is not true about preprocessor directives?


  1.    These are lines read and processed by the preprocessor
  2.    They do not produce any code by themselves
  3.    These must be written on their own line
  4.    They end with a semicolon
 Discuss Question
Answer: Option D. -> They end with a semicolon

None.


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
#define PI 3.14159
4.
int main ()
5.
{
6.
float r = 2;
7.
float circle;
8.
circle = 2 * PI * r;
9.
cout
  1.    12.5664
  2.    13.5664
  3.    10
  4.    compile time error
 Discuss Question
Answer: Option A. -> 12.5664

In this program, we are finding the area of the circle by using concern formula.
Output:
$ g++ cons.cpp
$ a.out
12.5664


Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int const p = 5;
6.
cout
  1.    5
  2.    6
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Error

We cannot modify a constant integer value.


Question 7.

The constants are also called as


  1.    const
  2.    preprocessor
  3.    literals
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> literals

None.


Question 8.

What are the parts of the literal constants?


  1.    integer numerals
  2.    floating-point numerals
  3.    strings and boolean values
  4.    all of the mentioned
 Discuss Question
Answer: Option D. -> all of the mentioned

Because these are the types used to declare variables and so these can be declared as constants.


Question 9.

How the constants are declared?


  1.    const keyword
  2.    #define preprocessor
  3.    both a and b
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> both a and b

The const will declare with a specific type values and #define is used to declare user definied 

constants.


Latest Videos

Latest Test Papers