Identifiers
The identifiers are user defined names used in programs for providing names to variables, arrays and functions. The identifiers are made up of letters(uppercase and lowercase), digits and underscore(_).
For Example,
int max; //max is an identifier which have datatype integer
int max2; //this is second identifier of same datatype
string max_3; //you can also use identifier like this with different datatype and underscore
float 4max; //you can not declare identifier like this this will generate an error
The C is case sensitive and hence the uppercase and lowercase letters are not treated as same.
For Example,
int max=20;// this is a different variable which assigns a value 20 to max
int Max=10; //this is different variable which assigns a value 10 to Max
Identifiers also used to identify functions. For Example,
int Add(); //this is a Function which is created for addition of two integer;
Program
Aim : - This Program will help you to understand how the function and variable can be differs from letters.
#include <stdio.h>
int add(int x, int y); //add is a function created to do addition;
void main()
{
int A=20,a=10; //this both are different variables
int sum;
sum=add(A,a); //this is function call which stores answer into variable named sum
printf("Addition: %d\n", sum);
}
//function body part
int add(int x,int y)
{
int m;
m=x+y;
return m; //this statement will return variable m to function add() which will store in sum
}
Output: -
Addition : 30
For Example,
int max; //max is an identifier which have datatype integer
int max2; //this is second identifier of same datatype
string max_3; //you can also use identifier like this with different datatype and underscore
float 4max; //you can not declare identifier like this this will generate an error
The C is case sensitive and hence the uppercase and lowercase letters are not treated as same.
For Example,
int max=20;// this is a different variable which assigns a value 20 to max
int Max=10; //this is different variable which assigns a value 10 to Max
Identifiers also used to identify functions. For Example,
int Add(); //this is a Function which is created for addition of two integer;
Program
Aim : - This Program will help you to understand how the function and variable can be differs from letters.
#include <stdio.h>
int add(int x, int y); //add is a function created to do addition;
void main()
{
int A=20,a=10; //this both are different variables
int sum;
sum=add(A,a); //this is function call which stores answer into variable named sum
printf("Addition: %d\n", sum);
}
//function body part
int add(int x,int y)
{
int m;
m=x+y;
return m; //this statement will return variable m to function add() which will store in sum
}
Output: -
Addition : 30
Comments
Post a Comment