Function, String, String input function, String output function, Array, One and Two Dimensional Arrays
To view other topics related to Computer. Click Here.
Function: -
A function is the collections of statements, which are used for any specific task.
Types of function: - There are two types of function in C language.
- Built in function
- User define function
(1) Built in function: -
Those functions which are already the parts of C language. The compiler already has known these functions. These functions are called built in functions. A built in function is also called a library function, a system defined functions.
For example
Scanf ( ), printf ( ), gets ( ), puts ( ), sin ( ), cos ( ) etc.
(2) User define function: -
These functions which a user create by it self and are not the part of the library file, are called user defined functions. These functions can only be use with in that program in which these are created and cannot in other program.
For example
Factorial of a number etc.
String: -
The collection of characters is called a string.
For example
“Pakistan” is a string
A string is always enclosed in double quotes.
String input function: -
To input a string we use get ( ) function and its format is:
Get (variable);
String output function: -
To display a string on screen we use puts ( ) function. The syntax of a string output function will be as:
Puts (variable);
ARRAY: -
It is the combination of same data type or if same data is needed more then none time then we use array.
Types Normally there are two types of array.
- One dimensional array
- Two dimensional array
(1) One dimensional array: -
This array is in form a list (vertical\Horizontal) the data input output or process in one dimensional array with the help of loop.
The syntax of one dimensional array will be as:
Array name [strength]
For example
A [5];
The structure of above syntax will be as:
A (0)
A (1)
A (2)
A (3)
A (4)
(2) Two dimensional array: -
Two dimensional array is also called a table because it consist of rows and columns. The syntax of two dimensional arrays will be as:
Data type array name [rows] [columns]
For example
Int [3] [2];
The structure of above syntax will be as:
A [0] [0] A [0] [1]
A [1] [0] A [1] [1]
A [2] [0] A [2] [1]
The data input output are process in this array with the help of nested loop.
Post a Comment