Declaring Multiple Variables in C: A Quick Guide
Learn how to efficiently declare multiple variables of the same type in C programming using a simple, comma-separated list. This section provides a clear explanation and examples to streamline your variable declarations.
C Declare Multiple Variables
Declare Multiple Variables
To declare more than one variable of the same type, you can use a comma-separated list:
Example
int x = 5, y = 6, z = 50;
printf("%d", x + y + z);
Assigning the Same Value
You can also assign the same value to multiple variables of the same type:
Example
int x, y, z;
x = y = z = 50;
printf("%d", x + y + z);