0% found this document useful (0 votes)
22 views

Introduction To C Programming

Uploaded by

nusrat della
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Introduction To C Programming

Uploaded by

nusrat della
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Bangladesh Army University of Engineering &

Technology
Department of Information and Communication Engineering (ICE)

Fundamentals of ICT
ICE 1111

 Mursheda Nusrat Della


 Lecturer
Lecture 18  Dept. of ICE
 BAUET

Information and Communication Engineering (ICE), BAUET


Introduction to C
Programming
Language

Information and Communication Engineering (ICE), BAUET


History of C Language
History of C language is interesting to know. Here we are going to discuss a brief history
of the c language.
C programming language was developed in 1972 by Dennis Ritchie at
bell laboratories of AT&T (American Telephone & Telegraph), located in
the U.S.A.
Dennis Ritchie is known as the founder of the c language.
It was developed to overcome the problems of previous languages such as
B, BCPL, etc.
Initially, C language was developed to be used in UNIX operating
system. It inherits many features of previous languages such as B and
BCPL.
Let's see the programming languages that were developed before C
language.

Information and Communication Engineering (ICE), BAUET


Language Year Developed By
Algol 1960 International Group
BCPL 1967 Martin Richard
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

Information and Communication Engineering (ICE), BAUET


Why to Learn C Programming?
C programming language is a MUST for students and working professionals to become
a great Software Engineer specially when they are working in Software Development
Domain. I will list down some of the key advantages of learning C Programming:
•Easy to learn
•Structured language
•It produces efficient programs
•It can handle low-level activities
•It can be compiled on a variety of computer platforms

Information and Communication Engineering (ICE), BAUET


Applications of C Programming
C was initially used for system development work, particularly the programs
that make-up the operating system. C was adopted as a system development
language because it produces code that runs nearly as fast as the code written
in assembly language. Some examples of the use of C are -
•Operating Systems
•Language Compilers
•Assemblers
•Text Editors
•Print Spoolers
•Network Drivers
•Modern Programs
•Databases
•Language Interpreters
•Utilities
Information and Communication Engineering (ICE), BAUET
1) C as a mother language
C language is considered as the mother language of all the modern programming
languages because most of the compilers, JVMs, Kernels, etc. are written in C
language, and most of the programming languages follow C syntax, for example,
C++, Java, C#, etc.
It provides the core concepts like the array, strings, functions, file handling, etc. that
are being used in many languages like C++, Java, C#, etc.
2) C as a system programming language
A system programming language is used to create system software. C language is a
system programming language because it can be used to do low-level programming
(for example driver and kernel). It is generally used to create hardware devices, OS,
drivers, kernels, etc. For example, Linux kernel is written in C.
It can't be used for internet programming like Java, .Net, PHP, etc.

Information and Communication Engineering (ICE), BAUET


3) C as a procedural language
A procedure is known as a function, method, routine, subroutine, etc. A procedural
language specifies a series of steps for the program to solve the problem.
A procedural language breaks the program into functions, data structures, etc.
C is a procedural language. In C, variables and function prototypes must be
declared before being used.
4) C as a structured programming language
A structured programming language is a subset of the procedural
language. Structure means to break a program into parts or blocks so that it
may be easy to understand.
In the C language, we break the program into parts using functions. It makes the
program easier to understand and modify.

Information and Communication Engineering (ICE), BAUET


5) C as a mid-level programming language
C is considered as a middle-level language because it supports the feature of both
low-level and high-level languages. C language program is converted into assembly
code, it supports pointer arithmetic (low-level), but it is machine independent (a feature
of high-level).
A Low-level language is specific to one machine, i.e., machine dependent. It is
machine dependent, fast to run. But it is not easy to understand.
A High-Level language is not specific to one machine, i.e., machine independent. It is
easy to understand.

Information and Communication Engineering (ICE), BAUET


Basic Component of a c program
A C program basically has the following component:
1. Preprocessor Commands
2. Functions
3. Variables
4. Statements & Expressions
5. Comments

Information and Communication Engineering (ICE), BAUET


C Basic Program and
Explanation
S.
no
Code Explanation

1. #include <stdio.h> This is a preprocessor command that includes


standard input output header file(stdio.h)
from the C library before compiling a C
program
2. int main() This is the main function from where
execution of any C program begins
3. { This indicates the beginning of the main
function.
4. /*_some_comments_*/ whatever is given inside the command “/*
*/” in any C program, won’t be considered for
compilation and execution
5. printf(“Hello_World! “); printf command prints the output onto the
screen.
6. return 0; This command terminates C program (main
function) and returns 0.
7. } This indicates the end of the main function.
Information and Communication Engineering (ICE), BAUET
Comments in C

 A comment is a note to yourself or others that you put in your


source code.
 All comments are ignored by compiler.
 Comments are used primarily to document the meaning and
purpose of your source code , so that you can remember later
how it functions and how to use it.
 Comments are mainly two types :
 Single line Comment
 Multi line Comment

Information and Communication Engineering (ICE), BAUET


Single Line Comment

 Single Line Comment is used to comment out just Single Line in


the Code. It is used to provide One Liner Description of line.
Basic Characters of Single Line Comment:
1. Single Line Comment Can be Placed Anywhere except the
middle of any c keyword, function name, or variable name.
2. Single Line Comment Starts with ‘//’
3. Any Symbols written after ‘//’ are ignored by Compiler
4. Comment cannot hide statements written before ‘//’ and On the
Successive new line

Information and Communication Engineering (ICE), BAUET


Multi Line Comment

Multi line comments can extend over several line or may be confined
within a line.

Basic Characters of Multi Line Comment:


1. Multi line comment can be placed anywhere except the middle of
any c keyword, function name, or variable name.
2. Multi line comment starts with /*.
3. Multi line comment ends with */.
4. Any symbols written between '/*' and '*/' are ignored by Compiler.
5. It can be split over multiple lines

Information and Communication Engineering (ICE), BAUET


Let us consider another example:

#include <stdio.h> //This is needed to run printf() function.


int main()
{
printf("C Programming"); //displays the content inside quotation
return 0;
}

Output
C Programming

Information and Communication Engineering (ICE), BAUET


Explanation of How this program
works
 Every program starts from main() function.
 printf() is a library function to display output which only works if
#include<stdio.h>is included at the beginning.
 Here, stdio.h is a header file (standard input output header file)
and #include is command to paste the code from the header file
when necessary. When compiler encounters printf() function and
doesn't find stdio.h header file, compiler shows error.
 Code return 0; indicates the end of program. You can ignore this
statement but, it is good programming practice to use return 0;.

Information and Communication Engineering (ICE), BAUET


Escape Sequences
Escape Sequences Character

\b Backspace
\f Form feed
\n Newline
\r Return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\' Single quotation mark
\" Double quotation mark
\? Question mark
\0 Null character

Information and Communication Engineering (ICE), BAUET


Steps to write C programs and
get the output:
 Below are the steps to be followed for any C program to create
and get the output. This is common to all C program and there is
no exception whether its a very small C program or very large C
program.

Information and Communication Engineering (ICE), BAUET


Sample questions
 Explain the necessity of C programming.
 Describe the applications of C programming
 Justify that “C programming is called procedural and structured programming
language”.
 Why C programming is called mid-level programming language?
 Mention the Basic Characters of Multi Line Comment.
 Apply the Steps to write C programs and get the output
 Define the Escape Sequences of C programming.
#include <stdio.h> //This is needed to run printf() function.
int main()
{
printf("C Programming"); //displays the content inside quotation
return 0;
}
 Find out the output of the above program and Explanation of How this program works.
 Define Comments in C programming with it’s classification.
 Describe C Basic Program basic structure with syntax.
Information and Communication Engineering (ICE), BAUET

You might also like