Variables and Data Types Interview Questions

    Question 1C++ Variable Declaration

    What is the correct way to declare an integer variable named count in C++?

    Question 2C++ Guess the Output - Integer Division

    What will be the output of the following C++ code snippet?

    #include <iostream> using namespace std; int main() { int x = 7, y = 3; cout << x / y; return 0; }

    Question 3C++ Character Data Type

    Which of the following data types is used to store a single character in C++?

    Question 4C++ Guess the Output - ASCII Conversion

    What will be the output of the following C++ code snippet?

    #include <iostream> using namespace std; int main() { int num = 'A'; cout << num; return 0; }

    Question 5C++ Boolean Data Type

    What values can a bool data type hold in C++?

    Question 6C++ Guess the Output - Floating Point Precision

    What will be the output of the following C++ code snippet?

    #include <iostream> using namespace std; int main() { float x = 5.0/2; cout << x; return 0; }

    Question 7C++ Size of Data Types

    Which operator in C++ is used to determine the size of a data type or variable?

    Question 8C++ Guess the Output - Type Casting

    What will be the output of the following C++ code snippet?

    #include <iostream> using namespace std; int main() { int a = 7, b = 2; double result = (double)a / b; cout << result; return 0; }

    Question 9C++ Variable Initialization

    Which is the correct way to initialize a variable in C++?

    Question 10C++ Global vs Local Variable

    Which statement is true about global and local variables in C++?