Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OVERVIEW OF ‘C’ PROGRAM

533 views

Published on

Published in: Technology, Business
  • Be the first to comment

OVERVIEW OF ‘C’ PROGRAM

  1. 1. OVERVIEW OF ‘C’ PROGRAM BY SAHITHI NARAPARAJU
  2. 2. INTRODUCTION  C was introduced by “Dennis M ritche” in 1978.  C is a structured programming language.  C is portable language this means that C programs written for one computer can be run on another computer with little modification or no modification.  Another important feature of C is its ability to extend.
  3. 3.  C program is basically collection of functions that are supported by C library. We can continuously add our own functions to C library.  The C compiler combines the capabilities of an assembly language with the features of a high-level language.  Programs written in c are efficient and fast. This is due to its variety of data types and powerful operators.
  4. 4.  Sample C program: main() { /*…………….. printing begins………………*/ printf (“Hello how r u?”); /* ……………………printing ends……………….*/ }  Output of the program is : Hello how r u?  Main() is a special function used by C to tell the compiler where the program starts.  Every program must have exactly one main function.
  5. 5.  If we use morethan one main function, compiler cannot understand which one marks beginning of the program.  The empty pair of parentheses followed by main function indicates that the function has no arguments.  The opening brace “ { ” marks the beginning of the main function and closing brace “}” indicates end of the function.  All statements between “{ ” and “}” these braces form function body.  Function body contains set of instructions to perform the given tasks.
  6. 6.  The function body contains 3 statements out of which only the printf line is an executable statement.  The lines beginning with /* and ending with */are known as comment lines.  Comment lines are not executable statements.  A C program can be viewed as a group of building blocks called functions.  A function is a subroutine that may include one or more statements designed to perform a specific tasks.
  7. 7. AN OVERVIEW OF C PROGRAM A C program consists of following sections: a) Documentation section b) Link section c) Definition section d) Global declaration section e) main function section e) subprogram section  2) Main function consists of 2 parts namely: Declaration part and Executable part  Subprogram section contains all the user defined functions.  1)
  8. 8. Documentation section Link section Definition section Global declaration section main() function section { Declaration part Executable part } Sub program section Function 1 Function 2 user defined function …. Function n
  9. 9.  Documentation section consists of a set of comment lines giving the name of the program, the author and other details which programmer would like to use later.  Link section provides instructions to the compiler to link function from the system library.  Definition section defines all symbolic constants.  Every C program must have one main() function section.  The section contains 2 parts declaration part and executable part.
  10. 10.  Declaration part declares all variables used in executable part.  The 2 parts must appear between opening and closing braces.  All statements in declaration and executable parts end with semicolon (;).  The subprogram section contains all the user-defined functions that are called in main function.  User-defined functions are generally placed immediately after main function, although they may appear in any order.
  11. 11. EXECUTING A C PROGRAM  Executing a program written in C involves a series of steps.  These are 4 steps involved in executing a C program: Creating the program. Compiling the program. Linking the program with functions that are needed from the C library. Executing the program. 1) 2) 3) 4)

×