Monday, June 22, 2015

Getting Started With C

Learning C is just like learning any other language and is easier.Instead of straight away learning how to write programs,we must first know the Alphabets,numbers and special symbols which have been used in C,and then how with the help of these constants,variables and keywords are constructed and how are these combined to form an instructions.
You can best understand this with the help of below flow chart example:

Steps in learning English Language:

Alphabets->Words->Sentences->Paragraph.

Steps in learning C Language:

Alphabets                   Constants              
Digits                     -> Variables           -> Instructions  ->Program.
Special Symbols         Keywords

In C we have three types of Character Set:

Alphabets:                 A,B,C,............,Y,Z.
                                  a,b,c,................,y,z.
Digits:                       0,1,2,3,4,5,6,7,8,9

Special symbols:       ~ ` ! @ $ % # ^ & * ( )_-+={}[] | \ : ; " ' < , > . ? /

The alphabets,digits and special symbols when properly combined form constants,variables and keywords.

Constant: A constant is an entity that doesn't change.
Variable: A variable is an entity that may change.
Keyword:A keyword is a word that carries special meaning.


Constants are further classified into two categories:
 (i)-Primary Constants.
(ii)-Secondary Constants.


Primary Constants->a:Integer Constant.
                                 b:Real Constant.
                                 c:Character Constant.
Secondary Constant->a:Array
                                    b:Pointer
                                    c:Structure
                                    d:Union
                                    e:Enum. etc.


In this  discussion we discuss only Primary Constants and rest later.

Rules For Constructing Integer Constants:

1- An Integer constant must have at least one digit.
2- It can be positive or negative.
3-If no sign precedes an integer constant,it is assumed to be positive.
4-No Commas or blanks are allowed with in it.
5-It must not have a decimal point.
6-The allowable range for integer type constant is:
        -2147483648 to +2147483647. for compilers like gcc,Visual Studio etc.
    and -32768 to +32767 for compilers like Turbo C++ etc.

eg:
     895
     -9645
    +789
      12

Rules For Constructing Real Constants:

These constants are also called as Floating Point Constants
The real constants can be written in two forms
Fractional Form and
Exponential Form.

Rules which we have to keep in mind while constructing these as in Fractional form:
1-It must have at least one digit and have a decimal point
2-It could either be positive or negative.
3-Default sign is positive.
4-No commas and blanks are allowed
Eg::
        +596.58
         36.25
         -0.28

In exponential form the real constant is represented as in two parts :The part appearing before 'e' is called mantissa where as part after 'e' is  called as exponent.Thus 0.000896 can be written in exponential Form as 8.96e-4.

Rules for exponential form is:
1-The two parts(Mantissa and Exponential)  must be separated by letter 'e' or'E'.
2-Default sign of Mantissa part and Exponent part is positive but it may have positive or negative           sign.    
3-The exponent must have at least one digit.
4-Range of real constants is -3.4e38 to +3.4e38 

Rules For Constructing Character Constants:

1-It is a single alphabet,single special symbol or a single digit enclosed within single inverted                commas.
2-Both commas should point to left i.e.'B' where as 'B` is invalid.

Eg:
      'S'
      'd'



--------------------------------------------------------------------------------------------------------------------------
In next post i will describe you about C variables and C keywords after that i will show you the programming portion of C.






Sunday, June 21, 2015


Introduction To C

Before I began to show you how to write serious programs in C language,it would be interesting to make you find out what really C is,How it came into programming world and how you can differentiate it with other languages .
In this blog we would briefly outline these things.
Apart from C in any language we have four important aspects on which whole body of programming language exist they are :
->The way it stores the data
->the way it operates upon this data.
->How it traverses the input and output.
->And How it lets you to control the Sequence of execution of instructions in a program.

What is C ?

C is a programming Language developed at AT & T's Bell Laboratories of USA in 1972.
It was designed and written by Dennis Ritchie .

Possibly why C seems so popular is because it is reliable,simple and easy to understand and use.Moreover ,in present industry where newer languages and technology emerges and vanishes day in day out ,a language that has survived for more than three decades has to be really good.
An opinion that is often heard in present is that "C has been already Superseded by languages like-C++,C# and JAVA  so why bother to learn C ?"

There are several reasons regarding this question:

1-Though Languages like C++,C# and JAVA make use of principles of Object Oriented programming(OOP) to write a program.Though this technique have lots of advantages .But even while using this organizing principle you still need to hold a good knowledge of programming skills which can better obtained by learning C. Though it's a long way ,but end it will definitely find it worth trouble.

2-Though many languages came into existence but still major  parts of popular operating system like Linux,Windows e.t.c.  are still written in C.This is because when it comes to performance level no other language beats the C.

3-Sometimes one is required to interact with the hardware device very closely.Since C provides Several  Language Elements that make the interaction easier without comprising the Computer Performance.

There are lot more Areas in Programming World where the performance matters programmers prefer to use C.I hope you get it  why C is essential for Beginners.
  In Next post we will more Discuss about Getting Started with C.