Variables and Data Types Interview Questions

    Question 1: C++ Variable Declaration

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

    Question 2: C++ 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 3: C++ Character Data Type

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

    Question 4: C++ 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 5: C++ Boolean Data Type

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

    Question 6: C++ 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 7: C++ Size of Data Types

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

    Question 8: C++ 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 9: C++ Variable Initialization

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

    Question 10: C++ Global vs Local Variable

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