Popular Posts

Saturday, July 19, 2008

INTRODUCTION TO C


INTRODUCTION TO 'C':

C is a programming language developed at AT & T's Bell
laboratories of USA in 1972.it was designed by dennis rechie.

where C stands:

a)problem oriented languages or high level languages:
these languages have been designed to give a better programming
efficiency.i.e,faster program development.
languages in this category are FORTRAN,BASIC,PASCAL etc.

b)machine oriented languages or low level languages:
these languages have been designed to give a better machine efficiency,i.e,faster program execution.
languages in this category are assembly language and machine language.

CONSTANTS,VARIABLES AND KEYWORDS

CONSTANTS,VARIABLES AND KEYWORDS:

CONSTANTS:

Two types of constants those are:
a)primary constants
b)secondary constants

a)In primary constants they are integer,real,character constants.
b)In secondary constants they are array,pointer,structure,union,enum etc.

VARIABLES:

a variable is a dataname that may be used to store a data value.unlike constants that
remain unchanged during the execution of a program,a variable may take different values at different times during execution.

Rules for constructing variables:

1. they must begin with a letter.some systems permit underscore as the first character.
2.ANSI standard recognizes alenght of 31 characters.however,the lenght should not be normally
more than eight characters,since only the first eight charaters are treated as significant by
many compilers.
3.uppercase and lower case are significant.that is,the variable total is not the same as total or TOTAL.
4.the variable name should not be keyword.
5.white space is not allowed.

example: int a=10;//int is a datatype,a is a variable in which '10' value is stored.

KEYWORDS:

keywords are the words whose meaning has already been explained to the compiler.
this cannot be used as variable names because if we do so we are trying to assign a new meaning to the keyword.
some of the keywords are
auto                            double                 if                      static
break                           else                   int                     struct
case                            enum                 long                   switch
char                           extern               near                  typedef    etc

DATATYPES

DATATYPES:

there are 3 types of datatypes those are:
a)primary datatypes
b)user-defined datatypes
c)derived data types


primary datatypes are: int,float,char,double etc.
user-defined datatypes are: typedef
derived datatypes are: arrays,pointers,structures,union,enum etc.