Lecture 03
Lecture 03
Introduction to C
Sachintha Pitigala
© 2023
C Programming Language
● Designed by Dennis Ritchie (1972)
● Used for developing UNIX OS
2
C Features
● Structured programming, modular programming
● Highly portable
● Efficient (fast)
4
First C Program
● Multi-line Comment
/* Multi-line comment
A first program in C */
● Lines beginning with # are processed by the preprocessor before the program
is compiled.
● Above include line tells the preprocessor to include the contents of the standard
input/output header (<stdio.h>) in the program.
● This header contains information used by the compiler when compiling calls to
standard input/output library functions such as printf. 11
Main Function
● int main()
● General form;
printf(format descriptor, var1, var2, …);
13
printf() Command
● The backslash (\) is called an escape character.
● When a newline appears in the string output by a printf, the newline causes the
cursor to position to the beginning of the next line on the screen. 14
Some Common Escape Characters
Sequence Description
\n New Line. Position the cursor at the beginning of the next line.