Sunday 12 August 2012

Getting Start with C


Getting Start with C 

History of C Programming Language


C Language is designed by Dennis Ritchie at Bell Laboratories in the early 1970s.
C Language  is Influenced by various early Languages like ALGOL 60 , CPL , BCPL , B.
The Language B is interpreter-based. 
Interpreter is a translator program that convert one line at a time. 
Hence B language programs were slow during translation into machine coding.
Dennis Ritchie modified B language and made it as compiler-based.
Compiler is a translator program that convert entire file at a time. 
The modified compiler-based B language is named as C.

What is C?


C is a Programming Language:
        Possesses powerful low-level features of 2 G Languages.
        Provides loops and constructs of 3 G Languages.
       Is very powerful and flexible - Procedure Oriented Programming Language.

C Features
Key features that made C as a widely-used language
1. Pointer
       Allows to refer the memory location - using address Operator & and Pointer Operator *
2. Memory Allocation
       Allows static as well as dynamic memory allocation ( using malloc() ) .
3. Recursion
       It is a  functions in which a functions calls itself.  Example - Factorial.  n ! = n * (n-1) !
4. Bit Manipulation  
       Allows manipulation of data in its lowest form of storage such as 0 & 1.



C is case-sensitive programming Language.

The General Structure of C Program:

Pre-process Directive

sub function declarations ;

void main()
{

    /*  main Function statement */
     /* Sub_function calling Statements */
  .............................
}

 sub_function definition
{
.............................
}


Once you create a program, the program has to be saved with .C file extension.
Depends on your compiler and Operating System, you may also use different  file extension.

Various Compiler Programs are used to work with C, like
  1.    Borland Turbo C
  2.    gcc
  3.    Micro Soft C


Working with Turbo C++ Version 3.0

To create and compile the C Programs using Turbo C++ ver 3.0

This Compiler comes with Editor Program called as IDE ( Integrated Development Environment)
Hence you can type , save, compile, edit and Run the Program in one program window

1. From windows, move to the Command Prompt (cmd)
2. If the Turbo C is installed in C:\TC\BIN path,
   Type the following DOC commands in Command Prompt :
   1. cls - to clear dos screen
   2. cd\ - to move the Root Drive
   3. cd   tc\bin - to move to Tc\Bin directory ( Turbo C Installation directory )
   4. tc - to open the Turbo C Compiler - Editor
       Turbo C - window has opened.

Within Turbo C,  create and save the "C' File as follow :
File -> New  : To create a New File 
File -> Save  : To Save the File into Harddisk Drive
    Type the File Name along with Path ( Drive & Folder )
     c:\prog\p1.c
Type the Program
Again save the file. File->Save.
Compile -> Compile  : To Compile the Program
If no Errors, Run-> Run : To Execute the Program
Window ->Output  : To view the output message.
Window ->Close : To Close the current Window.

If Error is displayed, then press enter key and Read the Error message.
Press the Enterkey to point the Error and Clear the Error.
Save , Re-Compile and Execute the Program..

The General Program Structure

/* Comments – Program Heading */
#include <Header Files>
Global variable declaration ;
FunctionReturnType main()
{
   variable declaration Statements ;
   Screen Clear Function calling ;
 Initialization ;
 Assignment ;
 Input Statements ;
   Control / Decision Making Statements
   Output statements ;
   function calling Statements ;
   Return Statements ;
}




No comments:

Post a Comment