Fundamental of Programming Language

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 80

Fundamentals of

Programming Languages-I

Prof.Laxmi Thakare
FPL - 1
 Teaching Scheme:
◦ Theory: 2 hr/week
◦ Practical: 4 hrs/week

 Examination Scheme:
◦ Online: 50 marks
Syllabus Overview
 Unit 1 - Introduction to Computer
 Unit 2 - Programming language ‘C’
 Unit 3 - Decision Control Structures in
‘C’, Pointers in ‘C’
 Unit 4 – Arrays in ‘C’, Functions in ‘C’,
Strings in ‘C’.
Books for Reference
 Yashavant Kanetkar, “Let Us C” – BPB Publications
 Brian W. Kernighan, Dennis M. Ritchie, “The C
Programming Language”, Prentice Hall, ISBN
0131103628, Second Edition
 Behrouz A. Forouzan, Richard F. Gilberg,
“COMPUTER SCIENCE – A Structured
Programming approach using C”, Indian Edition,
Thomson, 3rd edition
UNIT I
Introduction to Computer
Contents
 Computer Fundamentals
 System software's
 Introduction to computer programming tools
 Software development life cycle (SDLC)
 Open source software's
Introduction to Computer
 Intelligent machine has a great impact on
our day–to-day activities.
◦ Eg: Online Booking tickets (Railways, Airlines,
Movies, ATM machines, First year admission
process, etc
 Reduces paperwork, data storage capacity
is more.
Definition of Computer
 Computer is defined as “an electronic
device that is able to take raw input or
data from a user, store it, process it and
eventually output information as per
requirements”.
Features of Computer
 Automatic
 Accuracy
 Speed
 Reliability
 Storage capacity
Generations of Computer
 First Generation (1945-1954)
 Second Generation (1955-1964)
 Third Generation (1965-1974)
 Fourth Generation (1975-1989)
 Fifth Generation (1990 – till date)
Difference Engine and Analytical
Engine
 It an automatic, mechanical calculator designed to
tabulate polynomial functions.
 Invented by Charles Babbage in 1822 and 1834
 It is the first mechanical computer.
Some Important Facts
 First Computer programmer- Augusta Ada Byron (1840)
 First electro-mechanical computer- Havard Mark 1 (IBM Automatic
Sequence Controlled Calculator (ASCC)) . Invented by Howard H.
Aikenin 1943
 First programmable computer- Z1. Created by Konrad Zusein
Germany from 1936 to 1938.
 First electronic digital computing device- Atanasoff-Berry
Computer(ABC).
 First electronic general-purpose computer- ENIAC (Electronic
Numerical Integrator and Computer). Developed by John Presper
Eckertand John W. Mauchl.
 First commercial computer- UNIVAC I (UNIVersal Automatic
Computer 1). Designed by J. Presper Eckert and John Mauchly.
 The First Stored Program Computer- EDVAC (Electronic Discrete
Variable Automatic Computer) . Designed by Von Neumann in 1952.
 First portable computer- Osborne 1
 First computer company - Electronic Controls Company. Founded in
1949 by J. Presper Eckert and John Mauchly.
First Generation( Vacuum Tubes)
Second Generation(Transistors)
Third Generation (ICs)
Fourth Generation
(Microprocessor)
Fifth Generation(AI)
Block Diagram of Computer
Main Memory

CPU

Control Arithmetic/
unit logic unit
Input devices Output devices
Register storage area

Secondary
storage
Basic Operations of Computer
 Inputting-Process of Entering data & instruction in Computer.

 Storing- Storing data and instruction so they are available for


additional processing as and when required.

 Processing-Performing Arithmetic and logical operation on data in


order to convert them into useful information.

 Outputting-the process of producing useful information or


Result for the user as a printed report or visual display.

 Controlling –directing the manner and sequences in which all the


above operations are performed.
Input Devices
 Input devices are means to collect information from
the user and insert into the computer.
 Eg:- keyboard, mouse, scanner, joysticks, digital
cameras, etc
Output Devices
 Output devices make the information resulting from
the processing available for use.
 Eg: Monitors (VDU), printer, speaker, projector, etc.
Storage Devices
 Data is stored in the
Memory
memory
types
 It is measured in bytes.

Primary (Main Memory) Secondary


RAM,ROM HDD,CD,PenDrive

Unit Symbol

Kilobyte KB 1024B

Megabyte MB 1024KB

Gigabyte GB 1024MB

Terabyte TB 1024GB
Primary Storage Devices
 Memory (Primary) also called as Random
Access Memory or RAM is the main memory
of the computer.
 It is the temporary memory i.e volatile of the
computer.
 It consists of electronic components that store
data including numbers, letters or graphics and
sound.
 Any information stored in RAM is lost when the
computer is turned off.
Primary Storage Devices
 Read Only Memory or ROM is the memory that is
etched on a chip that has startup directions for your
computer .

 It is permanent memory.

 Types of memory
◦ RAM : Random Access Memory
◦ ROM : Read Only Memory
◦ PROM : Programmable Read Only Memory
◦ EPROM : Erasable Programmable Read Only Memory
◦ EEPROM : Electrically Erasable Programmable Read Only
Memory
Secondary Storage Devices
 Auxiliary storage devices are used to
store data when they are not being used
in memory.

 The most popular types of auxiliary


storage used on personal computers are
floppy disks, hard disks, CD-ROM drives,
removable drives, etc
Central Processing Unit(CPU)
 Central processing unit (CPU)
• A hardware component that performs computing
functions utilizing the ALU, control unit, and registers.

 Arithmetic/logic unit (ALU)


• Performs mathematical calculations and makes logical
comparisons

 Control unit(CU)
• Coordinates flow of data in/out of ALU, registers,
primary and secondary storage, and various output
devices
CPU
 Registers
• High-speed storage areas used to temporarily
hold small units of program instructions and
data immediately before, during, and after
execution by the CPU

 Most popular CPU manufacturers are


Intel and AMD
Hardware
 To function properly a computer needs both
software and hardware .
 Hardware is a component of computer system which
refers to physical components of computer system.
Eg: Input Devices, Output devices, Storage devices,
etc
 The hardware can function only if associated system
software (device driver) is installed
Software
 Software is a component of computer system which
constitutes set of instructions telling the computer how to
process data.

 The set of instructions are usually referred “Program”.

 Software can be divided into two types :


◦ System Software
◦ Application Software
Application Software
 A software which is developed for the use of
end-users is an application software.

 Eg:
◦ Railway reservation system (IRCTC website)
◦ Shopping websites (Amazon.com)
◦ Office Automation (Word, Excel, Powerpoint)
◦ Utility softwares (notepad, calculator, calendar, etc)
System Software
 System software consists of programs that
manage the hardware resources of a computer
and perform required information processing
tasks.

 Examples of System software are : Operating


System, Complier, Linker, Loader, Assembler,
Editor, etc
Operating System
 An operating system (OS) is system
software that manages computer
hardware and software resources and
provides common services for
computer programs.

 For hardware functions such as input


and output and memory allocation, the
operating system acts as an
intermediary between programs and
the computer hardware.
Commonly Used OS
Editor
 An editor (text editor) is a program that
enables users to create and edit text files.
 A source code editor is a text editor program
which has been designed specifically to be used
by programmers to edit source codes of
computer programs.
 Eg:Turbo C, gedit etc
Compiler
 A compiler translates a program written in a
high-level language (source language) to simpler
assembly language (target language).

 It replaces a single high-level statement with a series of


assembly language instructions.

 During the translation process, the compiler goes


through the entire source program and checks for syntax
errors.
High Level language Assembly Code
Program
(Source code) Compiler Error Message
Assembler
 An assembly language is developed only for the convenience
of the user to prevent the complexities related to the
machine language.
 An assembler converts assembly language code into
machine code which is ready for execution by the
computer hardware.
Linker
 When an application is broken into
several modules, each source
program (module) can be written
and compiled independently.

 These independent programs are


then linked together to create a
complete application.

 The software tool used for linking


together such modules is known as a
linker.

 A linker links together several


object modules and libraries to
form a single coherent program
Loader
 A loader is a system program that places the
object program into main memory and
prepares it for execution.

(Present in auxiliary
storage)
General Problem Solving
 We make decisions everyday for daily tasks.
◦ Eg: What to watch on television, Choosing a new
profession, etc.
◦ Bad decision leads to waste of time and resources.

 Six steps to ensure best decision


1. Identify the problem
2. Understand the problem
3. Identify the alternative ways to solve the problem.
4. Select the best ways to solve the problems from the list
of alternative solutions.
5. List instructions that enable you to solve the problem
using the selected solution.
6. Evaluate the solution
Problem Solving using Computers
 Program Problem solution Task

 The term solution means the instructions listed during step


5 of problem solving.

 Result means the outcome or the completed computer-


assisted answer.

 Program means the set of instructions that make up the


solution after they have coded into a particular computer
language.

 Computers are built to deal with algorithmic solutions,


which are often difficult or very time consuming for
humans.
Computer Programming
 A computer programming language refers to an
artificial language used to communicate with a
machine, especially a computer, in order to in
instruct it to carry out specific tasks.

 It is a set of grammatical rules to control the


behavior of a machine and make it follow specific
instructions.

 Current programming languages provide freedom


to programmers to concentrate more on logic
with less efforts.
Program Planning Tools
 Before starting with the actual task of
writing program, the programmers make
use of program planning tools to design
the program.
 Program planning tools are:
1. Algorithm
2. Pseudo code
3. Flowchart
Algorithm
 An algorithm is a self-contained step-by-step set of
operations to be performed.

 Algorithms perform calculation, data processing, and/or


automated reasoning tasks.

 It is an efficient method which uses a list of well


defined instructions to complete a task, starting from a
given initial state to achieve the desired end state.

 Types of algorithms : Brute force, greedy, divide n


conquer, dynamic programming, heuristic, etc
Characteristics of Algorithm
1. Finiteness
2. Definiteness
3. Input
4. Output
5. Effectiveness
Algorithm for sending message to
friend
Step 1: Unlock the phone
Step 2: open the Manu & go to Message app
Step 3: Select option “create Message”
Step 4: Now type the message and send it
Algorithm to Finding biggest of two
numbers.
 Step1: Start
 Step2: Read A,B
 Step3: If A>B,
then BIG=A,
otherwise BIG=B
 Step4: Write BIG
 Step5: Stop
Algorithm (Example)
 Algorithm to find out number is odd or even
step 1 : start
step 2 : input number
step 3 : rem=number mod 2
step 4 : if rem=0 then
print "number even"
else
print "number odd"
endif
step 5 : stop
Advantage of Algorithm
1. Simple to understand
2. Easy to debug
3. Independent of programming language
Flowchart
 A flowchart is a visual representation of the
sequence of steps and decisions needed to
perform a process.

 Each step in the sequence is noted within a


diagram shape.

 Steps are linked by connecting lines and


directional arrows.

 This allows anyone to view the flowchart and


logically follow the process from beginning to
end.
Purpose of Flowchart
1. Provide better communication
2. Provide an overview
3. Help in algorithm design
4. Check the program logic
5. Help in coding
6. Better documentation provided
Limitation of Flowchart
1. Time consuming
2. Difficult to modify
3. No standard available
Basic Control Structures
1. Sequence
◦ Steps that execute in sequence are represented by symbols that
follow each other top to bottom or left to right.
◦ Top to bottom is the standard.
2. Selection
◦ Once the condition is evaluated, the control flows into one of
two paths.
◦ Once the conditional execution is finished, the flows rejoin
before leaving the structure.
3. Loop
◦ Either the processing repeats or the control leaves the
structure.
◦ Notice that the return line joins the entry line before the
question.
Sequence
Selection
Loop
Symbols in Flowchart
Input: two numbers x and y
Output: the average of x and y
Steps:
 1.input x
 2.input y
 3.sum= x + y
 4.average= sum / 2
 5.output average
Draw a flowchart to find the largest of
three numbers A, B, and C.
To check if number is even or odd
Pseudo code
 Pseudo-code is an informal way to express the design of a computer
program or an algorithm.
 The aim is to get the idea quickly and also easy to read without
details.
 Pseudo code is an artificial and informal language that helps
programmers develop algorithms.
 It is also known as Program Design Language (PDL)
 The following basic logic are sufficient for writing any computer
program and the pseudocode is composed of all these:
◦ Sequence
◦ Selection (IF…. THEN or IF…THEN….ELSE)
◦ Loop or iteration (DO………WHILE or REPEAT…..UNTIL)
Advantage of Pseudocode
1. The conversion of a pseudocode to a
program is much easier than a flow
chart
2. Pseudocodes are much easier to modify
as compared to a flowchart
3. Less time and effort is involved while
writing a psuedocode in comparison to
a flowchart
Pseudo code (Example)
 To check if number is prime or not
Software Development Life Cycle
 SDLC is the process consisting of a series of planned activities to
develop or alter the software products.
 SDLC, Software Development Life Cycle is a process used by
software industry to design, develop and test high quality software.
 It is also called as Software Development Process.
 The SDLC aims to produce a high quality software that meets or
exceeds customer expectations, reaches completion within times
and cost estimates.
 Following are the most important and popular SDLC models
followed in the industry
◦ Waterfall Model
◦ Iterative Model
◦ Spiral Model
◦ V-Model
◦ Big Bang Model
◦ Other related methodologies are Agile Model, RAD Model, Rapid
Application Development and Prototyping Models.
Why SDLC?
 It offers a basis for project planning, scheduling, and
estimating
 Provides a framework for a standard set of activities
and deliverables
 It is a mechanism for project tracking and control
 Increases visibility of project planning to all involved
stakeholders of the development process
 Increased and enhance development speed
 Improved client relations
 Helps you to decrease project risk and project
management plan overhead
SDLC Phases

 Phase 1: Requirement collection and analysis


 Phase 2: Feasibility study
 Phase 3: Design
 Phase 4: Coding
 Phase 5: Testing
 Phase 6: Installation/Deployment
 Phase 7: Maintenance
Open Source Software's
 What is open source?
─ Source code is released to the general public
with relaxed or non-existent copyright
restrictions.
 Free to use
 Free to change
 Free to distribute
 Alternative to commercial/ licensed
software's.
Examples of Open Source
Application Softwares
 Eclipse
 Open Office
 7-zip
 Apache
 Perl, Python, Ruby
 PHP
Open Source Operating System
 What is an OS?
 What is an Open Source Operating
System?
◦ The code of open source operating system is
made available to the user.
 Examples
◦ Linux
◦ Ubuntu
◦ Fedora
◦ BOSS
BOSS
 Bharat Operating System Solutions
 Developed by C-DAC
 Currently BOSS GNU/Linux Desktop is available in all official
indian languaues such as bengali, gujarati, hindi,oriya, punjabi,
urdu, telugu, sanskrit etc
 EduBoss is a version for Indian schools and educational
institutes
 Latest version of BOSS(V 6) is named as Anoop- targeted
for government domain
 BOSS is derived from DEBIAN
 Features
◦ User-friendly Graphical Installer
◦ Indian version of open office- BharatheeyaOO
◦ Presentation tool
◦ Plug & play support for hardware
GCC
 “GNU Compiler Collection” is a
compiler system produced by the GNU
Project supporting various programming
languages.
 First version released in 1987
 Command for C compiler
◦ gcc
 Command for C++ compiler
◦ g++
Screen shot
Recap
 What is computer
 Hardware, Software
 Compiler, Assembler, Linker, Loader
 Problem solving using computer
 Planning tools : Algorithm, Flowchart
 SDLC
MCQs
Q. Computer has

A. Input device, Output device, Storage unit, CPU

B. Control Unit, Arithmetic unit

C. Central processing unit

D. Input device, Output device, Storage unit


MCQs
Q. Which is not a Input device

A. Scanner

B. Joysticks

C. Printer

D. Keyboard
MCQs
Q. Which is not a output device

A. Monitors,Visual Display Unit

B. Video games

C. Speakers

D. Keyboard

You might also like