Typed variable
Try it yourself →Variable with a specified type.
Syntax
type name = value;
Description
C is statically typed: int (integer), float/double (decimal), char (character). The type is written first.
Example
#include <stdio.h>
int main() {
int age = 36;
double height = 1.72;
char letter = 'A';
printf("%d %.2f %c\n", age, height, letter);
return 0;
}Expected output
36 1.72 A
When to use?
Storing all kinds of data.
Common mistakes
- ⚠️ char with single quotes: 'A'. Text (character array) with double quotes: "Alex".