Identifier In C

Page Contents:

1.Constants and variables:
2.Function:
3.Class:
4.Object :
5.STRUCTURE :
6.UNION :

Identifiers : Identifiers are names given to different user defined elements like variables,constants,functions,classes,object,structure,unions,etc.

  • The identifier can consist of alphabets, digits and a special symbol i.e. ‘_’ (underscore).
  • An identifier cannot start with a digit. It can start either with the alphabet or underscore.
  • It cannot contain any special symbol except underscore Blank spaces are also not allowed.
  • The identifier cannot be a keyword.
  • These are case sensitive i.e. an alphabet capital in one identifier with the same name in another identifier with that alphabet small case will be considered different.
  • Earlier, there was a limit of the length of the identifier to be 32 characters, but now this limit is removed. Hence, an identifier can be as long as required and a minimum of one character.

1.Constants and variables:


In this case Constants, values are given to the identifiers that do not change their value throughout the execution of the program. constants defined either by writing the keyword const before the data type or by using #define. The variable is the temporary storage of data with a certain memory location.

constants in C
constants in C
variables in C
variables in C

2.Function:

  • Accordingly, Function is a self-contained block of statements that performs a given task
  • The program we were writing until now had only one function i.e the main function
the syntax of function is given below:

return_type function_name(argument_list)
{
-
-
statements;
-
-
}

3.Class:

  • A class definition specifies the name of the class and the name and types of the class members
  • Generally, definition begins with the keyword class followed by the class name
  • For instance, the Data members and methods take place in the subsequent code block
  • Data members and member functions can belong to any valid type, even to another previously defined class.
class ClassName
{
Access specifier;
Data members;
member function()
{
-
-
-
}

}

4.Object :

  • An object defined in the usual way by supplying the type and the object name.

5.STRUCTURE :

  • The structure is a collection of multiple data elements that can be of different data types.
struct structure_name
{
data_type variable_name;
data_type variable_name; 
-
-
};

6.UNION :

  • The memory space required to store one variable of union is equal to the memory space required by the largest element in the union.
  • syntax of union is a collection of multiple data elements that can be of different data types. But, only one of these data items can be stored in the union variable.
  • Let us see the syntax of a union declaration.
syntax of structure declaration:
union union_name
{
data_type variable_name; 
data_type variable_name; 
-
-
};

Let us start with our First program:

  1. Write a program to display the statement “HELLO FRIENDS”.
#include<stdio.h> //(It tells us about input/output library)
#include<conio.h>
void main()     //(defining a funtion that receving no argument)
{
printf("HELLO FRIENDS")   //(printing statement by using printf funtion)
getch();       //(function used to accept one character from the user)
}

OUTPUT:
HELLO FRIENDS

But operation are missing from the above example.

Translate »