*

*

Fundamentals of C Programming

Wednesday, May 14, 2014

Introduction:

              C is one of most used and liked programming language in the world.Most of the programmer like it for programming.From different perspective of programming such as-program coding,
compilation,application and utilization etc.,C language is specialized compared to the other language. Even making some development C language is now converted to object oriented programming language C++.
C is such a programming language that one can be a skilled programmer by practicing it regularly.

 

Some Basics:

               For the novice programmer some essential topics are included in as follows which will help to understand the programming:

Program:

               An appropriate set of instructions which can solve the definite problem and give a desired output is called program.
Given instructions are stored in computer memory and these can be executed anytime.For execution of  program following tasks should be done:
-A set of instruction should input to the computer memory by means of input device such as key board,pen drive etc. 
-Input data should be processed by the processor for desired output.
-Output data need to display by output device like monitor,printer etc.
Fig.1: Input output system.

Terminal:

               All input-output device like-keyboard,scanner,monitor,printer,plotter etc.are called terminal.

Machine language:

               Computer system only can understand machine language that means 0 and 1.Writing machine language is hard and bothersome.
                             -Program coding is very difficult,
                             -Time consuming,
Though writing machine language have some difficulties but it is more efficient.

Programming language:

               The limitation of machine language is removed by developing programing language.On the other hand  the efficiency of program and machine remain excellent.Traditional English,Chinese, Malay,are not the programming  language.Creating environment for writing program,linking associate file with main file,debugging,translation,execution,saving,closing and opening file are operated sequentially.

Translator:

               Programming language is translated to machine language or 0 and 1 through translator.It is mainly a programming software.There are different types of translator.
  1. Assembler
  2. Interpreter
  3. Compiler

Hardware and Software:  

               Computer parts like- mouse,keyboard,monitor,microprocessor etc. are called hardware.On
the other hand program,programming language,operating system,translator which are required for the operation of hardware are called software.

 

Types of programming language:

Programming languages can be classified into three types:
  1. Low level language
  2. Mid level language
  3. High level language
Low level language:
               In this type of language some mnemonics like ADD,SUB,MOV,LOAD etc. are used instead of binary code 0 and 1.Assembly language is the example of low level language.Assembly language is translated into machine language through assembler.
High level language:
               High level language is not based on symbol or symbolic word.It is like English language.
To use this language it is not required to learn the internal structure of the computer in detail.Ada Modula-2,Pascal,COBOL,FORTRAN,BASIC these are some high level language.Interpreter or compiler is used to translate this high level language into machine language.
Mid level language:
               C/C++,FORTH,Macro-assembly language etc. are the examples of mid level language which has the properties of both high and low level language.

Special features of C programming:  

1.A mid level language:  
               C is called mid level language  because it support some feature of high level language and also some of low level language.

2.A structured language:
                C language is a combination of small function or module that’s why it is easy to test,debug,maintain and execution.

3.A portable language:
               C code is extremely portable that means all computer support C program.As for example a C program written in Apple computer can easily transfer to the IBM PC.

4.A general purpose language:
               C is called general purpose language because it is effective for all kind of purposes.

5.Not a typed language:
               All though C has five basic built in data type but it not a typed language like
Pascal or Ada.

Basic Structure of C program:

               The basic structure or format of C program is consists with a main function with one or more function.There are required statements in function or sub-routine to perform specific task.General format of C program is shown below:
Fig.2:Basic structure of c program.
Documentation section:
               Some comments line or comment statements are stated in this section,these lines has no effect on execution of the program.But these will help to know about the program name,program related information.Two forward slash (//) is used for single line commenting and /* and */ are used as starting and ending respectively for many line commenting in C.

Link section:
               Some header files are linked by #include directives.Compiler treat these files as a part of main file due to link.Compiler copy necessary data from library function or built in function during compilation.Linking is must for program execution.The format of linking is  #include<header file name>
 Example:  #include<stdio.h>
  
Definition section:
               All symbolic constants are described by #define directives.
 Example: #define pie 3.1416

Global declaration section:
              Variables used in many function are called global variable.Global variables are declared in above of all function.

Main function:
               A main()  function is must has to be in C program.There are two part in main function,declaration part and executable part.Variables used in executable part are declared in declaration part.At least one statement is must needed in executable part.A semicolon (;) must have to use in main function after each statement.In main function all statements are written between { }.

Subprogram:
               This program are usually known as user defined function.This functions are called from main function.These function can be written above or below the main function.User defined function is used to make easier and understand the program.
         

No comments:

Post a Comment