Introduction to c:
c is a programming language developed at Bell Laboratories of USA in 1972. it was designed and written by a man named Dennis Ritchie.
Literals/Constants
the value or quantity that never change during the execution of the program is known as constant value.
types:
its types:
a). Decimal Integer Constant:-
it cab have digit from 0 to 9 e.g. 23,89 etc.
b). Octal Integer Constant:-
it can have digits from 0 to 7 and also starts from 0(zero). e.g. 023 etc.
c). Hexadecimal Integer Constant:-
it can have digits from 0 to 9 and A to F but starts from 0x.
e.g. 0x23,0x85AB etc.
2). Floating point /Real Constant:-
A value having decimal points. its types are
a). Decimal Type:-
eg. 2.0,3.07 etc.
b). Exponential Type:-
eg. 5.6Ed,5.6e-5
3).Character Constants:
A Single digit or a single alphabet or any special symbol enclosed within single quotes is known as character constant. e.g. 'A','a','2','*' etc.
there are 256 character constants in c/c++ and each having a pre assigned value called ASCII value. It occupy one byte space in memory.
4). String Constant:-
A Single digit or a single alphabet or any special symbol enclosed within double quotes is known as String Constant.
e.g. "A","b","Mohit" etc.
Each String Constant terminates with NULL character(\0). It automatically Inserted by the compiler at the end of the string. e.g. "bce" it becomes in memory"bce\0"
Array:-
Array is an ordered collection of homogeneous types of data elements. here by homogeneous we mean elements/values of same type i.e. int or float or char etc and by ordered we mean data is stored at continuous memory locations.
generally array is used to store and process bulk amount of data easily and efficiently. for e.g. to store and purchase bulk amount of data easily and efficiently.
types of array:-
1. 1-dimensional array:-
variable declared using single subscript is known as 1-d array.
eg. int a[4];
// different declaration cum initialization methods:
int a[]={2,4,6}; // occupy three locations
int a[]; // invalid declaration
int a[3]={3,5}; // 3rd location will be zero
int a[3]; // all will be garbage value
static in a[3]; // all values will be zero
int[n]; // variable are not allowed in subscript
2. 2-dimensional array:-
variable declared using two subscript is known as 2-d array. as shown below:
datatype variable[rows][column];
eg. int a[2][3];
c is a programming language developed at Bell Laboratories of USA in 1972. it was designed and written by a man named Dennis Ritchie.
Literals/Constants
the value or quantity that never change during the execution of the program is known as constant value.
types:
- Integer Constant
- Real Constant
- Character Constant
- String Constant
its types:
a). Decimal Integer Constant:-
it cab have digit from 0 to 9 e.g. 23,89 etc.
b). Octal Integer Constant:-
it can have digits from 0 to 7 and also starts from 0(zero). e.g. 023 etc.
c). Hexadecimal Integer Constant:-
it can have digits from 0 to 9 and A to F but starts from 0x.
e.g. 0x23,0x85AB etc.
2). Floating point /Real Constant:-
A value having decimal points. its types are
a). Decimal Type:-
eg. 2.0,3.07 etc.
b). Exponential Type:-
eg. 5.6Ed,5.6e-5
3).Character Constants:
A Single digit or a single alphabet or any special symbol enclosed within single quotes is known as character constant. e.g. 'A','a','2','*' etc.
there are 256 character constants in c/c++ and each having a pre assigned value called ASCII value. It occupy one byte space in memory.
4). String Constant:-
A Single digit or a single alphabet or any special symbol enclosed within double quotes is known as String Constant.
e.g. "A","b","Mohit" etc.
Each String Constant terminates with NULL character(\0). It automatically Inserted by the compiler at the end of the string. e.g. "bce" it becomes in memory"bce\0"
Array:-
Array is an ordered collection of homogeneous types of data elements. here by homogeneous we mean elements/values of same type i.e. int or float or char etc and by ordered we mean data is stored at continuous memory locations.
generally array is used to store and process bulk amount of data easily and efficiently. for e.g. to store and purchase bulk amount of data easily and efficiently.
types of array:-
1. 1-dimensional array:-
variable declared using single subscript is known as 1-d array.
eg. int a[4];
// different declaration cum initialization methods:
int a[]={2,4,6}; // occupy three locations
int a[]; // invalid declaration
int a[3]={3,5}; // 3rd location will be zero
int a[3]; // all will be garbage value
static in a[3]; // all values will be zero
int[n]; // variable are not allowed in subscript
2. 2-dimensional array:-
variable declared using two subscript is known as 2-d array. as shown below:
datatype variable[rows][column];
eg. int a[2][3];