CSC – 183
Programming C
Chapter - 1
Overview of C
Md. Mortuza Hossain
Assistant Lecturer, Department of CSE
IUBAT
October 27, 2023 CSC-183 1
Course Materials
• Text Book:
– Programming In ANSI C (5th Edition) by E Balagurusamy
– C – The Complete Reference by Herbert Schildt
• Additional Support:
– Class Lecture Slides
October 27, 2023 CSC-183 2
Course Outline:
• Introduction to C programming
• Constants, Variable & Data Types
• C Operators & Expressions
• Managing I/O Operations in C
• C Control Structure
• C Arrays
• C Characters and Strings
• C Functions
• C Pointers
• Structure and Union in C
October 27, 2023 CSC-183 3
Today’s Outline:
• Introduction to Programming
• History of C
• Why teach C
• What is C used for?
• Hello World! C Program
• Basic Structure of C Programs
• Programming Style in C
• Executing A ‘C’ Program
• Process for Executing A ‘C’ Program
• Rules to Remember.
October 27, 2023 CSC-183 4
Introduction to Programming
• What is a program?
– A computer program is a set of instructions that tell a computer
what to do.
• What is programming language?
– A programming language is a formal computer language
designed to communicate and give instructions to a machine,
particularly a computer.
• What is Programming C?
– C is a high-level and general purpose programming language.
October 27, 2023 CSC-183 5
History of C
• The root of all modern languages is ALGOL, introduced in
1960s.
• In 1967, Martin Rachards developed BCPL.
• In 1970, Ken Thompson created B by using BCPL features.
• In 1972, C was evolved from ALGOL, BCPL and B by Dennis
Ritchie at the Bell Laboratories on DEC PDP-11 machine.
Which referred as "Traditional C“.
• In 1978, introduced K&R C (Kerningham and Dennis
Ritchie).
• In 1989, ANSI approved a version of C known as ANSI C.
• In 1990, ISO also approved this version referred as C89.
• In 1999, Another enhanced version of C is introduced C99.
October 27, 2023 CSC-183 6
Why teach C / Importance of C
• C is small (only 32 keywords).
• C has rich set of built-in functions and support variety of data
types & operators.
• C is highly portable (Machine independent).
• C is structured.
• C has ability to extend itself.
• C is stable (the language doesn’t change much).
• C is quick running (code written in c is efficient & fast).
• C is the basis for many other languages (C++, C#, Java, Perl etc).
• C is a Programmers Language.
• It may not feel like it but C is one of the easiest language to
learn.
October 27, 2023 CSC-183 7
What is C used for?
• C is most likely an evergreen language.
• Initially, C widely known as the development language of
the UNIX operating system but today virtually all new
major operating systems are written in C and/or C++.
– Systems programming: OSes, like Linux.
– Microcontrollers: Automobiles and Airplanes.
– Embedded processors: Phones, Portable Electronics etc.
– DSP processors: Digital Audio.
October 27, 2023 CSC-183 8
Hello World! Program
October 27, 2023 CSC-183 9
Format of simple C programs
main() Function Name
{ Start of Program
………….
…………. Program Statements
………….
} End of Program
October 27, 2023 CSC-183 10
Basic Structure of C Programs
October 27, 2023 CSC-183 11
Basic Structure of C Programs (with Example)
/* Program for Print, Author: Mr. X */ Documentation Section
#include<stdio.h> Link Section
#define PI 3.1416 Definition Section
void print_pi(); Global Declaration Section
main() Function Section
int main() {
{
print_pi(); ………………
return 0; ………………
}
}
Subprogram Section
void print_pi() Function1()
{ {
printf("Value of PI is: %.4f",PI);
} }
October 27, 2023 CSC-183 12
Programming Style
• You should follow one style for programming.
• We must develop the habit of writing programs in
lowercase letters, because C programs statements are
written in lowercase letters.
• Uppercase letters are used only for symbolic constants.
• Braces, {} indicates beginning and end of a functions.
• Need, braces to align for easy readability.
• Try to write one statement into one line, although C
support multiple statement in a single line.
October 27, 2023 CSC-183 13
Executing A ‘C’ Program
• Executing a program written in C involves a series of
steps. There are:
1. Creating the program;
2. Compiling the program;
3. Linking the program with functions that are needed from the
C library;
4. Executing the program.
October 27, 2023 CSC-183 14
Process for Executing A ‘C’ Program
Edit
Program
Source
Code
Compile
Object
Code
Library Link Object
Files Code Executable
October 27, 2023 CSC-183 15
Rules to Remember:
• Every C program requires a main() program (more than
one main() illegal)
• Execution of a function begins at the { opening brace and
ends at the corresponding } closing brace.
• C programs are written in lowercase letters. Higher case
used for symbolic name and output strings.
• Every program statement in a C language must end with a
semicolon.
• include and define are special instruction s to compiler,
they do not end with a semicolon.
• Using comment /* Comment */ is a good programming
habit.
October 27, 2023 CSC-183 16
October 27, 2023 CSC-183 17
Thank You All
October 27, 2023 CSC-183 18