keyword identifiers c languages

Identifiers: Identifiers are used for the naming of variables, functions, and arrays. It is a string of alphanumeric characters that begins with an alphabet, or an underscore( _ ) that are used for variables, functions, arrays, structures, unions, and so on. It is also known as the user-defined word. Identifier names must differ in spelling and case from any keywords. We cannot use keywords as identifiers; they are reserved for special use. Once an identifier is declared, we can use the identifier anywhere in the program to refer to the associated value

Variables:   A variable is the name of a memory location that stores data. We can change the value of a variable, and we can also reuse it multiple times. A variable is a name that points to a memory location. It is the basic unit of storage in a program.
The value of a variable can be changed during program execution. All the operations are done on the variable effects that memory location. In C, all the variables must be declared before use.
e.g.
int a=15;
float b=4.5;
Variable is the most important part in a programming language. To understand better let say we want to calculate Area of Triangle. To make this calculations we need height ,base and its respective values. To store height and base of triangle we need some memory space for data or values. The name given that memory location is called Variable. For different data values we can give different names to memory location.
For better understanding ,let’s study the given image. It shows memory location where data value is stored with variable name myage and value is 22
int myage=22;

naming rule from variable declaration C Programming language

Rules to Declare Variables in C

In C language, we need to declare a variable with suitable data type and variable name.
Here are some of the rules we need to follow while declaring a variable in C:
• Variables should not be declared with the same name in the same scope.
• A variable name can start with anything like the alphabet and underscore. But the variable name should not start with a number.
• A variable name must not be a reserved keyword in C. For example, if you declare a variable name as label, int, float, char, function, else etc., then it will not be able to be used as a variable name.
• A variable name can contain any combination of alphabets, numbers and underscores.
• All the declaration statements must end with a semi-colon. (;)
• It is suggested to declare the variables of same data type in the same line.
• It will be better if we declare variable names with some meaningful names and then it clearly describes the purpose of the variable.

Declaration Variables in C

Variables in C Language Program need to be declared before using it. Variables can be declared with Data type and name of the Variable or identifier
Variables Declared in Two Ways:
i. Primary Type Declaration:
Primary type declaration is used to declare a variable with primitive data types, which are also called as built-in data types.
Most commonly used primary data types are int, float, char, boolean, double, long ,bool etc.

a. Single primary type declaration
Eg:- char Grade = 'A';
b.Multiple primary type declarations in the same line
When multiple variables are declared in the same line, we need to use a comma to separate the variables, as shown below.
Eg:- int Length= 12, Width = 13, Depth = 14;
ii. User-Defined Type Declaration:
User-Defined Type Declaration is a type of declaration where the data type is defined by the user.User or programmer has the flexibility to declare his own data type by using inbuilt data type.
Some of the most commonly used data types are struct, Union, enum, typedef etc.


1.Structure: Structures are used to group data items of different types into a single user-defined data type variable. Or we can group different data type using single variable. In Structure member or attributes does not share the memory location. Every member in structure occupy separate memory location.
2. Union: Unions are user-defined data types in which different type of members share a common memory location, so any one of them is accessible at a time. When we want to access only one member, then we use Union.
3. Typedef : is a keyword in C programming that is used to give new name to existing type. typedef keyword gives the meaningful name to existing type so that user will understand more friendly. We need to use the keyword typedef to define the data type. Now we can use those new data types in our program, as shown below.
typedef unsigned int unit;
here we have declared the unit variable of type unsigned int by using typedef keyword.

 variable and identifiers in C Programming