What is the default value of an uninitialized integer variable in C++?
- -1
- 0
- 1
- Undefined
In C++, the default value of an uninitialized integer variable is undefined. It means if you declare an integer variable and do not assign a value to it, then its value is anything; it can be any garbage value. Relying on or using this value leads to unpredictable results and is considered a bad programming practice.
Loading...
Related Quiz
- What is the main advantage of separating function declaration from its definition, especially in large projects?
- The ______ loop in C++ is unique because it evaluates its condition after executing the loop body, ensuring the loop body runs at least once.
- Imagine you are developing a Graphic Design Application where different types of shapes are drawn. Which OOP concept will simplify the code?
- A pointer passed by value to a function allows the function to change the _______ to which the pointer points.
- How does a break statement inside a nested loop behave?