C Programming language

adplus-dvertising
C Programming introduction

In this section we are going to provide C Programming introduction,Why use c programming,Advantages and disadvantages of C language,Why c is called middle level language,General Structure of c programs, and examples etc .

Previous Home Next

C Programming introduction

C is a programming language developed by AT & T’s Bell Laboratories of USA in 1972. C was originally designed for and implemented on the UNIX operating system on the DEC PDP-11, by Dennis Ritchie.It is a basically an outgrowth of two earlier language called BCPL and B .

In C there are 32 keywords and 40 operators.C is a general-purpose programming language with features economy of expression, modern flow control and data structures, and a rich set of operators.C is not a ``very high level'' language, nor a ``big'' one, and is not specialized to any particular area of application.

Why use C programming ?

C language is very prevalent in creating different applications and writing of several different software source-codes. The essential feature comprising C language includes the simple and straight-forward use of compiler with a low-level access to memory.

C programming is structure programming language we can add no. of module (function) according to our need. Here are some examples of structured and non structured languages:

Non StructuredStructured
FORTRANPascal
COBOLC++
C
Java
Modula-2

Advantages of C language

  1. C is a general-purpose programming language with features economy of expression, modern flow control and data structures, and a rich set of operators.
  2. C programming is structure programming language we can add no. of module (function) according to our need.

Disadvantages of C language

  1. There is no runtime checking.
  2. There is no strict type checking (for ex: we can pass an integer value for the floating data type).
  3. As the program extends it is very difficult to fix the bugs.

Why C is called middle level language ?

C is called middle level language because it is actually binding the gap between a machine level language and more conventional high level languages. user can use c language to do system programming (for writing operating system) as well as application programming (for generate menu driven customer billing system ). So that is called middle level language .

High level Language

Ada , Modula-2 , Pascal, COBOL, FORTRAN, BASIC

Middle level Language

Java , C++ , C, FORTH, Macro-assemble

Low level Language

Assembler

General Structure of c program

  1. Document section
  2. Pre-processor section
  3. Global section
  4. Main() Section

    {
    }

  5. User-Defined section
  1. Document section

    This section is related with user comment section .user can add comment two ways :

    • Single line comment: for single line comment user can add // two forward slash before for single line. User can add number of // single line comment in program.

      Example:

      // this is single line comment

    • Multiline comment: for multiline comment user can add /* */ User can add number of multiline comment.

      Example:

      /* this is multiline comment this is multiline comment this is multiline comment this is multiline comment this is multiline comment this is multiline comment */

  2. Pre-processer Directive section

    Normally every c program started with some Header files .that is called pre-processor section.

    Pre-processor section is a section where number of header files are included .basically its helpful to link some files with c program. With help of different header files we can access different function easily.

    Example:

    for access sqrt(), printf(), scanf(), getch(), functions different header files like:

     #include<stdio.h>, #include<conio.h> , #include<math.h>

    included in c program.
  3. Global Declaration Section

    Global section is helpful to declare some variable which we can access in all over program. Basically before main function we can declare different global variable. We can access those variable in all over program.

  4. Main Function section

    In c language there must be a main() function.this section contain two parts.

    • Declaration part: for declare variables

    • Execution part all statements between{…………} these braces are execute by c compiler.

  5. User defined section

    Users can add number of different function with different data type ..he can add called same function number of times in main() function also.

Example of “general structure of C program”


// this is comment section.
#include //these are header files
#include
int a; // this is global section
void main() // this is main section
{
Printf(“this is main section”) ;
}
int function() // this is user defined section
{
Printf(“this is user defined section”);

Is C case sensitive language ?

Yes … in capital letter and lower letter have different meaning in c language .so c language is a case sensitive language.

How to Execute a program in C ?

Creating a executable form of our C program have a three steps:

  1. Creating our program
  2. Compiling our program
  3. Linking our program
  1. Creating our program

    first we create our program in c language. that have a Document section, Pre processor section, global declaration section, main section, user defined section. With these section we create c program.

  2. Compiling our program

    after creating our program we do the compile that program. After compiling program that convert the program in .obj extension.

  3. Linking our program

    After finish these two steps we do linking of the program, linking time that include a some library files. After linking the program that create a .exe file of that program and that exe file always be execute. These three steps showing in the diagram

Previous Home Next