Identifier
Identifiers are the names given to program elements like as variables, arrays, etc. They are makes by using a sequence of letters (consisting of uppercase as well as lower case ), numerals(like 1,23,4 etc), and underscores.
Rules for identifiers in c
1. An Identifier can only have alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).
2. The first character of an identifier can only contain alphabet(a-z , A-Z) or underscore (_).
3. Keep in mind name and Name are two different identifiers in C.
4. Keywords are not allowed to be used as Identifiers.
5. No special characters, such as semicolon, period, spaces, slash or comma are allowed to be used in or as Identifier.
6.keep in mind identifier ‘VARIABLE’ is different from ‘variable’ and ‘Variable’.
Keywords
In c programming language there are 32 reserved word that are predefined.These words are called keywords in c programming Keywords can not use as identifier.All keyword
Table 1 Keywords list C language
Basic data types
Data type are that which tell to compiler what type of data programmer going to use in program.There are four basic data type in c programming int, float,double, character.Here only simple definition given.But you will learn in further deeply with program example.
Table 1.2
no.
|
Data type
|
Size in byte
|
use
|
1.
|
char
|
1
|
to store characters
|
2.
|
int
|
2
|
to store integer numbers
|
3.
|
float
|
4
|
to store floating point
|
4.
|
double
|
8
|
to store big floating point
|
Variables
In programming languages variable can be defined as it is a name given for help to give a memory in location in computer memory.Actually when programmer give a variable name then memory get located at a particular address.C language support two types of variable.
For example -
int a=12;
a=15;
here int is data type and keyword.And a is variable as well as identifiers.
a
62343535

a
62343535
Here in example 62343535 is fixed address of a given variable and a is variable name.value at the address can be change during updating in program you will be understood further. In mathematics value of a variable can change and c programming value of a variable can be also change at a particular address.Here it is clear a variable give a memory location at a particular address.
For example -
int a=12;
a=15;
here int is data type and keyword.And a is variable as well as identifiers.
a
12
|
a
15
|
Here in example 62343535 is fixed address of a given variable and a is variable name.value at the address can be change during updating in program you will be understood further. In mathematics value of a variable can change and c programming value of a variable can be also change at a particular address.Here it is clear a variable give a memory location at a particular address.
Numeric variable
Numeric variable use to store integer values or floating point values. Modifiers like short, long, signed, and unsigned can also be used with numeric variables. The difference between signed and unsigned numeric variables is that signed variables can be either negative or positive but unsigned variables can only be positive.
Character variable
Character variables are just single characters enclosed within single quotes. Character set may be letters (‘a’, ‘A’), numerals (‘2’), or special characters (‘&’).
Declaration of variable
Declaration of variable means specify the data type of a variable that programmer will use in program.Data types written before the variable indicate which type of data will be store in variable.A variable name can be written as user wants but heed on rule.
For example -
int a=12;
Here int is a data type written before the variable indicate integer type value will be store in variable a.
Characters Allowed
Underscore(_)
Capital Letters ( A – Z )
Small Letters ( a – z )
Digits ( 0 – 9 )
Blanks & Commas are not allowed
No Special Symbols other than underscore(_) are allowed
First Character should be alphabet or Underscore
_var
var_num2
Tip 2 : blanks are not allowed
Invalid Names
Var 1
var 1
1 var
@var
1 var
@var
addition of program
Initializing of variable
While declaring the variables,we can also initialize them with some value.Initializing means declaration of variable with value.
For example, int emp_num = 100;
float salary = 105.50;
char grade = ‘B’;
double balance_amount = 800000000;
Constant
Constants are identifiers whose values do not change. While values of variables can be changed any time at particular address, values of constants can never be changed.
Declaration of constant
To declare a constant, precede the normal variable declaration with const keyword and assign it a value. const float pi = 3.1.
3 Comments
Thanks it is so written right way
ReplyDeleteAur bhi topoc upload kijiye
ReplyDeleteKya question poochh sakte hai
ReplyDeleteAny query comment in comment box thank you
Emoji