Variables
Functions in C consist of manipulating variables. These are items of data which we give a name to.
Every variable in C has an explicit type. These types are declared by ourselves or built into the language. We can declare a new variable by writing the name of its type, followed by its name, and optionally setting it to some value using =
. This declaration is a statement, and we terminate all statements in C with a semicolon ;
.
To create a new int
called count
we could write the following…
int count;
Or to declare it and set the value…
int count = 10;
Here are some descriptions and examples of some of the built in types.
void | Empty Type | |
char | Single Character/Byte | char last_initial = ‘H’; |
int | Integer | int age = 23; |
long | Integer that can hold larger values | long age_of_universe = 13798000000; |
float | Decimal Number | float liters_per_pint = 0.568f; |
double | Decimal Number with more precision | double speed_of_swallow = 0.01072896; |
当前内容版权归 orangeduck 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 orangeduck .