Created: 2023-01-10 15:47
Status: #concept
Subject: Programming
Tags: C
Initialize
Initialization is usually done with Variables to assign an initial value to them, before they are used for calculations or assignments.
C
Using variables without initializing them may cause the compiler to make an unexpected result such as;
2568
, -30891
, or another weird number.The program may also crash.
int x; // an uninitialized variable named 'x'
int y = 0; // an initialized varaible named 'y' with the value '0'
float a = 1, b = 2, c = 3; // we can also initialize multiple variables
References
- C Programming, A Modern Approach, 2nd Edition, Chapter 2.4