Skip to content

Variable in C

Format

DataType variableName;

or with default value

DataType variableName = defaultValue;
  • The variable must define before we using it.
  • The variable must end with ;.

Data Type

  • int, number without decimal
  • float, number with decimal
  • char, string
  • bool, true or false

INFO

For char we need use "" to wrap the data.

Example

c
// int, default value is 12
int age = 12;

float pi = 3.142;

char c = "sajsdj";

bool d;

d = false;