MCQ
Q.
Which of the following is the correct syntax to declare an integer variable named
count in C++ and initialize it with the value 10?
Correct Answer: A
The correct answer is int count = 10;.
🔑 Key Points
- In C++, a variable is declared by first specifying its data type, followed by the variable name.
- The assignment operator (`=`) is used to assign an initial value to the variable during declaration (initialization).
- Every statement in C++ must end with a semicolon (`;`).
intis the keyword for the integer data type.
📄 Additional Information
- Other basic data types in C++ include
float(for floating-point numbers),double(for double-precision floating-point numbers),char(for single characters), andbool(for boolean values: true/false). - Variables can also be declared without initialization, e.g.,
int count;, but it's good practice to initialize them to avoid undefined behavior.