A variable in C stores a value in memory.
It must be declared with a data type before it's used.
You can declare and assign a variable in one line or separately:
C supports different types of variables. Here are three common ones:
int: integersfloat: decimal numberschar: charactersYou can declare multiple variables of the same type on a single line:
Use const to create a variable whose value cannot change:
Variable names:
total ≠ Total)int or returnFormat specifiers tell printf() how to display the variable:
%d – integer%f – float%.2f – float with 2 decimal places%c – characterWhich of the following is invalid? Ask the AI chatbot to see if your answer is correct.
A. int speed = 100;B. const float pi = 3.14;C. int 1stPlace = 5;Hint: Variable names can’t begin with a number.
Ask the AI if you need help understanding or want to dive deeper in any topic