Variable and Constants and Their Types

Variable and Constants and Their Types

Variable and Constants and Their Types

To view other topics related to Computer. Click Here.

Variable and Its Types:

Variable: -

It is a space or a location where we keep some constant value. There are four types of variable in C language. (1) Integer variable (2) Float variable (3) Character variable (4) String variable

(1) Integer variable: -

A variable or a place we keep or put only integer constant is called integer variable. It is declared a deserved word ‘int’. For example a=5, then a will be integer variable.

(2) Float variable: -

A location or variable where we put some float or real data is called float variable. It is declared a deserved word ‘float’. For example a=5.55 then a will be a float variable.

(3) Character variable: -

A variable which keep only the character constant is called character variable. It is declared a deserved word ‘char’. For example a=’1’, now a will be a character variable.

(4) String variable: -

A variable which can store a string constant is called a string variable. For example a[8]= “ pakistan ” ; then a[8] will be string variable.

Constant and its types

Constant: -

A fix or unchangeable value in the program is called a constant value. There are four types of constant in C language. (1)Integer constant (2) Real or Float constant (3) Character constant (d) String constant

(1) Integer constant: -

A numerical value without a decimal is called integer constant. Or A non-frictional (+,-) fix value is called integer constant. For example +225, -555, 500 etc.

(2) Real or Floating constant: -

A frictional (+,-) fix value is called real or floating constant or Numeric values that an integer as well as a decimal part are called real or floating constant. For example +25.32, -58.679, 28.321 etc.

(3) Character constant: -

A single character when it is enclosed in single quotes is called character constant. For example ‘a’, ‘1’, ‘M’ etc.

(4) String constant: -

The combinations of characters when those are enclosed in double quotes are called string constant. For example “Pakistan”, “Phone-0966” etc.

Post a Comment

Previous Post Next Post