StudyGraph
Procedural Programming with C++ Guess first

What does int age; print? Guess first

Most students get this wrong: what does an uninitialised int print?

Lesson notes

Declare and initialise variables of fundamental types and explain how type sets size and range

Key points

Takeaway: An uninitialised local int is indeterminate, never guaranteed zero.

Quick check: In main(), int age; then cout << age; What prints?
  1. 0
  2. A compile error
  3. Unpredictable garbage

Local variables are not zeroed: always initialise, e.g. int age = 20;

data typeinitialisationscopeIndeterminate valueData type

Lessons like this, for your syllabus.

Short narrated study videos written for your course, level and exam. Free to start.

Get lessons for your own syllabus