Some example of such names:
- Average
- height
- Counter_1
- class_strenght etc.
Conditions Of Variables:-
Variable names may consist of letters , digits , and the underscore character, subject to the following condition:
1. They must start with a letter. Some systems permit underscore as the first character.
2. ANSI standard recognizes a length of 31 characters, however length should not be normally more than eight characters, since only the first eight characters are treated as significant by many compiler.3. Uppercase and lowercase are important. For example the variable Total is not the same as total or TOTAL.
4. It should not be a keyword.
5. White space is not allowed.
Variables Declaration:-
The variable represents the memory location and with its help, we can also change the access and access to memory location in programming, we can do this procedure in Variable Declaration.Scope Of Variables:-
How far a variable can work in a program. This is its scope. According to Scope the variables are divided into two categories:
1. Local Variables
2. Global Variables
Valid examples of decimal integer constants are:
123 - 321 +78 O 654321 etc.
Example: Source code
2. Global Variables
Local Variables:-
Local Variables inside the function. Local Variables are the function within which they are visible only. The default value of Local Variables is 'garbage value'.In other word, Local variables are variables that are defined in a small block of a program such as a function or control statement can be blocks or any other block. The use of such variables is limited only to this block. For example, if you have created a variable in a function, then you cannot access the variable outside the function.
Global Variables:-
Global variables are those variables whose scope is in the whole program.
Anybody can access these variables anywhere in the entire program.2. Constant:-
Constants in C refer to the fixed values that do not change during the execution of a program. Constant's value is fixed. If an attempt is made to change its value, an error occurs in the program. It can be of any data type. It is also called Literals. Constant is also Pointer.Type Of Constants:-
There is many types of constants which written below:- Integer Constant
- Floating-point / Real Constant
- Character Constant
- String Constant
Example:- This is a simple example of constants:
Integer Constants:-
An integer constant refers to a sequence of digits(whole numbers). There are three types of integers namely decimal integer, octal integer and hexadecimal integer. Decimal integers consist of a set of digits, 0 through 9, preceded by an optional- or +sign.Valid examples of decimal integer constants are:
123 - 321 +78 O 654321 etc.
Example: Source code
0 Comments