You are on page 1of 9

CHAPTER 1

OVERVIEW OF C

* All topics and points are not included.


1
Overview of C:
History

Ken Thompson (left)


Dennis Ritchie (right)
Bell labs, USA
Overview of C : Importance of C
• High level language

• Rich set of built-in functions and operators

• Only 32 keywords in ANSI C

• Highly portable

• Suited for structured programming (Modules / Blocks)

• Modular programming: debugging, testing and maintenance easy

• Ability to extend: can add user define functions to C library 3


Overview of C: Sample Prog. • Executable statement
• Predefine standard C function
• Every statement in C should end
with semicolon (;)
• main() Special function sample_code.c
• Where program starts
Function
• MUST have exactly body
ONE main() function Set of
Instructions
otherwise …
• Compiler: Which one “ { ” Beginning & • Comment Lines
“ } ” End of • Non executable statements
marks beginning of the • Ignored by compiler
a main() function.
program? • Can not be nested
• DO NOT effect execution speed and size of compiled program
4
Overview of C: Sample Prog.
sample_code.c

• Program that uses I/O


library functions
• Not necessary for printf
and scanf

• Distinct between UPPER CASE and lower case


• printf and PRINTF are not same
• Upper case used for symbolic constants
5
Overview of C : The main() Function
void before main() : • main ( ) Empty
Function DO NOT • int main ( ) parentheses:
function has no
return any • void main ( ) arguments
information to OS
• main (void) Indicate No
int before main() : • int main (void) arguments by
using void
Function DO • void main (void)
return integer keyword
value to OS int main() or int main(void)
{
return 0; /* last statement */
} 6
Overview of C : Basic Structure of C Program
add.c

7
Overview of C : Basic Structure of C Program

Program
Execution begins
at opening
bracket

Closing bracket is
a logical end of
the program

NOTE: All section except main() function section may be absent when they are not required.
8
Overview of C : Executing a ‘C’ Program

1. Creating the program


1.
2. Compiling the program
3. Linking the program with
functions needed from C
library
2,3.
4. Executing the program
4.

Output:
9

You might also like