Monday, September 7, 2020

Variables in C. declaration and initiallization

 * Identifiers:

1] Identifiers are used to identify variables, symbolic constants, functions, arrays etc.

2] Identifier names must be a sequence of letters and digits, and must begin with a letter.

3] These are user defined names.

4] Ex : sub1, sub2, total, roll_no, per[30], factorial();

* Variable :

1] An entity that may vary during program execution is called as variable.

2] A variable is a data name that may be used to store a different type of constants.

3] Ex : Average, height, Total, roll_no etc.

* Declaration of variable : 

1] Every variable must be declared before they are used .C doesn't allow  flexible declaration.

2] It means that declaration of variables, must be the first statement in a program.

3] The general declaration of variable is as follows.

Data Type Variable1, Variable2...;

  1) int phy. chem, bio, total;

  2) float percentage;

  3) char  name [30];

* Initialization:

1) C language allow as to give the initial value to the variable at the  time of declaration , it is referred as initialization of variable.

2) The general initialization of variable is as follows.

Data Type   Variable=value;

  1) int phy=60, chem=50, total;

  2) float percentage=70.50;

  3) char name [30]="kaya" ;



No comments:

Post a Comment

Object Paradigm Oriented Programming in C++ / object oriented programming / History of C++/ paradiagram in c++/C devolop, Operating System, Unix operating system, Assembly language, popular in world, Programming language.

  Object Paradigm Oriented Programming  Two programmers, Brian Kernighan and Dennis Ritchie developed a new language called C, in 1972.  C l...