C Identifiers
C Identifiers
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:
Also remember, identifier names must be different from keywords. You cannot use int as an identifier because int is a
keyword.
1. A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
4. 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.
Literals
Literals are data used for representing fixed values. They can be used directly in the code. For example: 1, 2.5, 'c' etc.
Here, 1, 2.5 and 'c' are literals. Why? You cannot assign different values to these terms.
Constants
If you want to define a variable whose value cannot be changed, you can use the const keyword. This will create a constant.
For example,
PI = 2.9; //Error
You can also define a constant using the #define preprocessor directive.
void
void is an incomplete type. It means "nothing" or "no type". You can think of void as absent.
For example, if a function is not returning anything, its return type should be void.
In C, signed and unsigned are type modifiers. You can alter the data storage of a data type by using them:
Data types that are derived from fundamental data types are derived types. For example: arrays, pointers, function types,
structures, etc.
All valid C programs must contain the main() function. The code execution begins from the start of
the main() function.
The printf() is a library function to send formatted output to the screen. The function prints the string inside
quotations.
To use printf() in our program, we need to include stdio.h header file using the #include <stdio.h> statement.
The return 0; statement inside the main() function is the "Exit status" of the program. It's optional.
When a character is entered by the user in the above program, the character itself is not stored. Instead, an integer value
(ASCII value) is stored.
And when we display that value using %c text format, the entered character is displayed. If we use %d to display the
character, it's ASCII value is printed.
C Bitwise Operators
During computation, mathematical operations like: addition, subtraction, multiplication, division, etc are converted to bit-
level which makes processing faster and saves power.