You are on page 1of 45

Introduction to C

Programming
History of c programming
Language year Developed By
ALGOL 1960 International Group
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K&RC 1978 Kernighan & Dennis
Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization
Committee
Features of C Language
There are many features of c language are given below.

1) Machine Independent or Portable


2) Mid-level programming language
3) structured programming language
4) Rich Library
5) Memory Management
6) Fast Speed
7) Pointers
8) Recursion
9) Extensible
  A Simple C Program: Printing a Line of Text (Cont.)

• Lines 1 and 2
• /* Fig. 2.1: fig02_01.c
A first program in C */
• begin with /* and end with */ indicating that these two
lines are a comment.
• You insert comments to document programs and
improve program readability.
• Comments do not cause the computer to perform any
action when the program is run.
  A Simple C Program: Printing a Line of Text (Cont.)

• Comments are ignored by the C compiler


and do not cause any machine-language
object code to be generated.
• Comments also help other people read
and understand your program.
• Keyword – predefined reserved words which convey
some meaning to compiler
• Identifier – element in a program or name to entity
Assignment statement
• An assignment statement gives a value to a variable
The general syntax of an assignment statement is

variable = expression;
Example Program

Output
Example Program
Output
PREPROCESSOR DIRECTIVES
•Before a C program is compiled in a compiler, source code is processed by a
program called pre-processor. This process is called pre-processing.
•Commands used in pre-processor are called pre-processor directives and they
begin with “#” symbol.

Preprocessor Syntax/Description 
 
Syntax: #define
Macro This macro defines constant value and can be any of the
basic data types.
Syntax: #include <filename>
Header file inclusion The source code of the file “filename” is included in the
main program at the specified place.
Syntax: #ifdef, #endif, #if, #else, #ifndef
Conditional Set of commands are included or excluded in source
compilation program before compilation with respect to the
condition. 
Syntax: #undef, #pragma
#undef is used to undefine a defined macro variable.
Other directives
#Pragma is used to call a function before and after main
function in a C program.
A program in C language involves into different processes. Below diagram will help
you to understand all the processes that a C program comes across.

You might also like