10/14/2024CSF,NU5
Books:
•Deitel& Deitel, C How to Program
•Let Us C by yashavant kanetkar
LANGUAGE
10/14/2024CSF,NU6
Language is a source of communication.
In general, there are two types of languages
Natural languages
Programming Languages
10/14/2024CSF,NU7
Natural languages
These are the languages through which the human beings
communicate with each other. For example: Arabic,English, French,
Pashto etc.
Programming languages
These are the languages through which the human beings
communicate with the computer. These are the most widely used
mediums between the user and the computer. Examples are C,
COBOL, PASCAL, BASIC, FORTRAN etc.
The programming languages are classified into three types:
Low level languages.
Middle level language
High level languages
Low-Level Language
10/14/2024CSF,NU8
•It consists of two types of languages
•Machine language
•Assembly language
•Machine language
•Machine Language was the first language used for computers as a source of
communication.
•This is the only language which is directly understandable by the machine
(computer) and needs no translation programs (compiler, Assembler,
Interpreter).
•Machine language is the language of binary digits 0’s and 1’s(“0” means
“OFF” and “1” means “ON) that is why it is also called as binary language. It
is very difficult to write programs using 0’s and 1’s i.e. in machine
language.
•Thus machine language is totally machine dependent and is efficient for
computers and inefficient for programmers.
10/14/2024CSF,NU9
A type of language in which instructions are written in
binary from is called machine language
It is the only language that is directly understood by the
computer
Low-Level Language
10/14/2024CSF,NU10
Assembly language
The computer professionals developed one step higher
language than the machine language which is called Assembly
language .
The binary codes of machine language (0’s and 1’s) were
replaced by some special codes called mnemonics.
The programs in Assembly language are written using these
mnemonic codes as: ADD for addition, SUB for subtraction
MUL for multiplication These mnemonics are understandable
by the human but not understandable by the machine.
To make it understandable for the machine, a program called
assembler is developed its function is to translate a program
written in assembly language into machine language
Low-Level Language
Middle level language
10/14/2024CSF,NU11
Middle Level Programming languages are closely related
toMachine as well as Human Being.
User can Use C language to do system programming for
writing operating system as well as application
programming.
10/14/2024CSF,NU12
These languages are fairly machine independent and English like.
High level languages are those languages in which programs are written
completely in English language. E.g. C++, Vb, Java, Python, PHP, R,…
The programmer can understand more easily and enable the programmer to
write instructions easily using English words and familiar mathematical
symbols such as if else, for, goto, +,-etc.
A program written in high-level language is translated into machine
understandable form with the help of Translation programs i.einterpreter or
compiler.
The high level languages are of two types:
Procedural languages/Structured languages.
OOP (Object Oriented Programming) languages
High Level Language
Aprocedural languageis a type of programming
language that follows a structured approach to programming
through the use of procedures or routines. Here are some key
characteristics:
Key Features
Procedure-Based:
Programs are organized into procedures (also known as
functions or subroutines) that contain a sequence of statements
to be executed.
10/14/2024CSF,NU13
Control Structures:
Utilizes control structures such as loops (for, while) and
conditionals (if, switch) to control the flow of execution.
Modularity:
Encourages breaking down complex problems into smaller,
manageable procedures, promoting code reuse and
organization.
Examples of Procedural Languages
C,PASCAL, COBOLE, FORTRON, BASIC, etc.
10/14/2024CSF,NU14
Object-Oriented Programming (OOP)is a
programming paradigm that uses "objects" to design
software.
PopularOOP Languages
Java
C++
Python
C#
Ruby
10/14/2024CSF,NU15
10/14/2024CSF,NU16
Is a special computer language used to create software.
A programming languageis a vocabulary and set of
grammatical rules for instructing a computer or computing device
to perform specific tasks.
A programming language is a set of commands, instructions, and
other syntax use to create a software program.
Languages that programmers use to write code are called "high-
level languages." This code can be compiled into a "low-level
language," which is recognized directly by the computer
hardware.
A language used to write instructions for the computer.
Every statement in a programming language is actually a command
to the computer to perform the specific task.
Programming Language
History
10/14/2024CSF,NU17
The C language was created by Dennis Ritchie in 1972 at AT& T
Bell laboratory in USA.
Before C language their were more basic languages that were
called Cobol and FORTRAN .1960
Fortran language was used in engineering and Cobolewas used in
commercial. after that in 1963 CPL language was created in
Cambridge university .
In 1965 Bcpllanguage was created .
In 1970 b language was created by ken tomson
In 1972 c language was created.
Fortran language
10/14/2024CSF,NU
1
8
FORTRAN stands for FORmulaTRANsaltingsystem .
It is used for engineering application and scientific use
BASIC LANGUAGE
Basic language is stand for beginner All purpose symbolic
instruction code
It was created at the late of 1960
It is used for education purpose
Cobol language
10/14/2024CSF,NU
COBOL stands for common Business Oriented Language
it is specially designed for business application
PASCAL LANGUAGE
PASCAL language is used for both scientific and business application
C-LANUAGE
10/14/2024CSF,NU
2
0
C-language is popular high level language
It was developed by Dennis Ritchie at AT& T Bell
laboratories in 1972
It provides the facilities to write application software as well
as system software
Why c language created?
C language is created for to run each kind of program.
Why C Still Useful?
10/14/2024CSF,NU21
C provides:
Efficiency, high performance and high quality s/w
many high-level and low-level operations middle level
Stability and small size code
Provide functionality through rich set of function libraries
Gateway for other professional languages like C++C#
Java
10/14/2024CSF,NU22
Advantages of C
C is an all purpose programming language, such as solving
scientific and engineering problems, business application and
operating systems.
Many modern languages (like C++, Java, and Python) are
influenced by C. Learning C provides a strong basis for
understanding these languages.
C is hardware independent language, it works in all types of
computers
C contains the features of both, the low level and high level
languages
C is rich in operators. There are about 45 operators available in C
C is structure programming, which easy to maintain program
C has many library functions
Learning of C language
10/14/2024CSF,NU23
We learn c language for the cause of base to the
following language
C++,Java,C#...
Basic element can be used in advanced element
Management of language is inherited from c language.
For C language we use compiler
Compiler translate all program into machine code or
machine language but all at once.
C++, C# or Java make use of a principle called Object
Oriented Programming (OOP) to organize programs which
offers many advantages. While using this organizing principle,
you need basic programming skills. So it makes more sense
to first learn C and then migrate to C++, C# or Java.
Though this two-step learning process may take more time,
but at the end of it, you will definitely find it worth the
trouble.
Major parts of popular operating systems like Windows,
UNIX, Linux and Android are written in C. Moreover, if one
is to extend the operating system to work with new devices,
one needs to write device driver programs. These programs
are written exclusively in C.
10/14/2024CSF,NU24
Common consumer devices like microwave ovens, washing
machines and digital cameras are getting smarter by the day.
This smartness comes from a microprocessor, an operating
system and a program embedded in these devices. These
programs have to run fast and work in limited amount of
memory. C is the language of choice while building such
operating systems and programs.
The popular gaming frameworks (like DirectX) that are used
for creating games are written in C.
10/14/2024CSF,NU25
Important issues for learning of language
10/14/2024CSF,NU26
So a group of instruction is called program
10/14/2024CSF,NU27
The C Character Set
10/14/2024CSF,NU28
C character set consists of Numeric characters, Alphabetic
characters and special characters to represent information
Numeric character are 0 … 9
Alphabetic character are upper and lower-case letter of the English
language (A,B,C,…Z, a,b,c,…z) .
The C Character Set
10/14/2024CSF,NU29
Special Character Set
The special characters are period (.), comma (,), Semicolon(;), Colon(:),
Single & double quotes (‘ & “), Plus & Minus sign (+ -), Asterisk(*),
Slash(/), Back Slash(\), Equal Sign(=), Parentheses( ), Percent sign(%),
Less and Greater sign(< >), Hash or number sign(#), Ampersand(&),
Question Mark(?), Opening and Closing braces ({ }),
and other special characters including the blank character which is
equivalent to a space on the keyboard
The C Character Set
Development with C
10/14/2024CSF,NU30
Four stages
Editing: Writing the source code by using some IDE or editor
Preprocessing or libraries: Already available routines
Compiling: translates or converts source to object code for a
specific platform source code →object code
linking: resolves external references and produces the
executable module
Portableprograms will run on any machine but…..
Note! Program correctness is most important