Vidyalelo
C++ Programming · all questions

Variables and Data Types in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

123

Questions

5/7

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
    enum channel {star, sony, zee};
    enum symbol {hash, star};
    int i = 0;
    for (i = star; i <= zee; i++) 
    {
        printf("%d ", i);
    }
    return 0;
}

Select an option to see the answer and solution.

What does '\a' escape code represent?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
    cout << setprecision(17);
    double d = 0.1;
    cout << d << endl;
    return 0;
}

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 num1 = 1.1;
    double num2 = 1.1;
    if (num1 == num2)
       cout << "stanford";
    else
       cout << "harvard";
    return 0;
}

Select an option to see the answer and solution.

How do we represent a wide character of the form wchar_t?

Select an option to see the answer and solution.

Which of the following statements are true?
int f(float)

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()
{
    int a = 5;
    float b;
    cout << sizeof(++a + b);
    cout << a;
    return 0;
}

Select an option to see the answer and solution.

Which of the following statements are false?

Select an option to see the answer and solution.

In C++, what is the sign of character data type by default?

Select an option to see the answer and solution.

Which of these expressions will isolate the rightmost set bit?

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 ( )
{
    static double i;
    i = 20;
    cout << sizeof(i);
    return 0;
}

Select an option to see the answer and solution.

Identify the incorrect option.

Select an option to see the answer and solution.

Choose the incorrect option.

Select an option to see the answer and solution.

Find the odd one out.

Select an option to see the answer and solution.

Which variable does equals in size with enum variable?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
enum colour 
{
    green, red, blue, white, yellow, pink
};
int main()
{
    cout << green<< red<< blue<< white<< yellow<< pink;
    return 0;
}

Select an option to see the answer and solution.

Which of the two operators ++ and - work for the bool data type in C++?

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()
{
    int i;
    enum month 
    {
        JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
    };
    for (i = MAR; i <= NOV; i++)
       cout << i;
    return 0;
}

Select an option to see the answer and solution.

What is the range of the floating point numbers?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.