Local & Global variable, Return statement, Calling & Called function, Source program, Object program, Unions, Structure, Pointer, Pointer Operators

Local & Global variable, Return statement, Calling & Called function, Source program, Object program, Unions, Structure, Pointer, Pointer Operators

Local & Global variable, Return statement, Calling & Called function, Source program, Object program, Unions, Structure, Pointer, Pointer Operators
To view other topics related to Computer. Click Here.

(1) Local variable: -

These variables which are used with in only that function, in which these are declared are called local variable. These variables cannot be used in the main ( ) program or in another program.

(2) Global variable: -

Those variables which are declared before main ( ) function and can be used any ware in the program.

(3) Return statement: -

This statement is use to bring a value from any function main ( ) program.

(4) Calling function: -

The written function of the main ( ) function is called calling function.

(5) Called function: -

A function which is written in main ( ) program is called function.

(6) Source program: -

A computer program written in a high level language is called source program. It is also called the source code.

(7) Object program: -

A computer program in a machine language is called the object program. It is also called the object code.

Unions: -

A union is a memory location just like a structure which has number of variables of different data type. The syntax of a union in C language is just like the structure syntax, such that:

Union name of union

{

Type member variables;

}

Union name of union using new name;

In this topic we also use a dot (.) operator with its new reference name.

For example

Union mem

{

Int a;

Char b;

};

Union name value;

So we can use its reference name value with its member variables as:

Value . a;

Value . b;

Structure: -

As we know that an array is the collection of same data type but structure is the collection of different data types or different variables or different field.

A structure is written as:

Struct name of structure

{

Type member’s variables;

};

Where the word struct is used for structure and it is a reserved word, which tells the compiler that we are introducing the structure and fields.

For example

Struct student record

{

Char name [15];

Char exam [10];

Int phy, che, math’s;

};

So the student name is the name of structure and name, exam are the fields of character type and phy, che, math’s are the fields of integer type.

Pointer: -

A pointer is a variable, which is used to store the address of another variable.

For example

If we have a variable ‘T’ whose address is 1000 and its value is 5 let ‘B’ another variable which has the address number 1000 of ‘t’ and it has address 1003 then it will be as:

Variable Address Values

T 1000 5

B 1003 1000

So we can say ‘B’ is keeping the address of variable ‘T’ so it will be a pointer.

Pointer operators: -

The operators ‘&’ and ‘*’ are called the pointer operators. These operators are used to point the address of a variable as well as the content (value) of a variable.

So the operator ‘&’ is used to store the address of operator and the operator ‘*’ is used to store the content of that variable.

The pointer variable is declared as:

Data type

Data type * variable name;

For example

Int *a;

So a will be a pointer variable if this variable a has value 5 and it is started on address 1000 then

Printf (“%d”, a); --------------- (i)

Printf (“%d”, &a); ------------- (ii)

Printf (“%d”, *a); -------------- (iii)

So the result of (i) will be 5 and the result of (ii) will be 1000 and the result of (iii) will be 5.

Post a Comment

Previous Post Next Post