Learning C Programming :
C is a procedural programming language. It was initially developed by Dennis Ritchie as a system programming language to write an operating system. The main features of C language include low-level access to memory, simple set of keywords, and a clean style, these features make C language suitable for system programming like operating system or compiler development
C Introduction
C Keywords and Identifiers
Character set
Digits
Special Characters
C Keywords
Here,
int
is a keyword that indicates money is a variable of type int
(integer).C Identifiers
Identifier refers to name given to entities such as variables, functions, structures etc.
Identifiers must be unique. They are created to give a unique name to an entity to identify it during the execution of the program. For example:
Here, money and accountBalance are identifiers.
Also remember, identifier names must be different from keywords. You cannot use int
as an identifier because int
is a keyword.
Rules for naming identifiers
- A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
- The first letter of an identifier should be either a letter or an underscore.
- You cannot use keywords like
int
,while
etc. as identifiers. - There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.
You can choose any name as an identifier if you follow the above rule, however, give meaningful names to identifiers that make sense.
C Variables, Constants and Literals
In programming, a variable is a container (storage area) to hold data.
To indicate the storage area, each variable should be given a unique name (identifier). Variable names are just the symbolic representation of a memory location. For example:
Here, playerScore is a variable of int
type. Here, the variable is assigned an integer value 95
.
The value of a variable can be changed, hence the name variable.