Translate

Friday, 2 November 2012

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:
  1. Integer Constant
  2. Real Constant
  3. Character Constant
  4. String Constant   
1). Integer Constant:-                      a value without decimal point is known as integer 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];

Thursday, 1 November 2012

data types:

      data types of a variable determine the type of constant a variable can store.
types of data types:
1. Fundamental / Primitive Data Type
2. Array
3.void
4.User Defined Data Types

VioSoftware.com
variable :
        variable is a storage location in the memory used to store some constant value. its value can be changed at run time.

Identifier:

      Identifier is fancy term used to mean "name". In C, identifier are used to refer to a number of things. It is used as a name of variable and Functions.

Rules for Identifier:
1). It Should start from Alphabet(Upper/lower) or underscore only.
 eg. Abc,hHk,h12,basic_sal(Valid),
12Basicsel(Invalid)
2).Upper Case and Lower case are considered different eg. int Bat,bat;(valid)
3). Key words are not allowed 
        eg. int float=45;(invalid)
             int Float=45;(valid) 

Key Words: 
             Key word refers to the reserved words in c/c++ which can't be used as a name of the variable etc.
 list of some of keyword:
  auto   const     double  float  int       short   struct   unsigned
break  continue  else    for    long      signed  switch   void
case   default   enum    goto   register  sizeof  typedef  volatile
char   do        extern  if     return    static  union    while