SlideShare a Scribd company logo
1 of 93
Download to read offline
CSEG1003 Programming for Problem Solving
CSEG 1003
Programming for
Problem Solving
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
Road Map
• Generations of Computers and Languages
• Organization of Computers
• Number Systems Conversion
• Logical Analysis and Thinking
Introduction
• Structure of C Program & Compilation and Linking Process
• Variables and Datatypes
• Managing Input and Output statements
• Decision and Looping Statements
C Programming
Basics
• Creation and Usages
• 1D and 2 D arrys
• String Functions
• Matrix operations
Arrays and
Strings
• Declaration and Definitions of Functions
• Passing Arguments
• Recursion
• Pointers & Pointer Arithmetic
Functions and
Pointers
• Need of Structure and Unions
• Declaration and Definition
• Storage classes
• Preprocessor Directives
Structures and
Unions
CSEG1003 Programming for Problem Solving
LECTURE #1
EVOLUTION ,GENERATION OF COMPUTERS &
CLASSIFICATION OF COMPUTERS
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
History
• Abacus
• Sliding Beads on a rack
• Counting purpose
• Operators on addition and subtraction
• 300 B.C.
• Napier Bones
• Logarithmic value carved on ivory sticks
• Scotsman ->John Napier
• 1617
CSEG1003 Programming for Problem Solving
Abacus – Addition and Subtraction
CSEG1003 Programming for Problem Solving
Napier’s Bones - Multiplication
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• Pascaline Machine
• Functional Automatic Calculator
• French Mathematician
• Blaise Pascal
• 1642
• gear-driven calculating machine
• Eight movable dials
CSEG1003 Programming for Problem Solving
Gear Engine
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• Leibniz's Stepped Reckoner
• 1694
• German Mathemacian
• addition, subtraction, multiplication, and division
• Jacquard Powerloom
• 1801
• weave automatically
• read from punched wooden cards
CSEG1003 Programming for Problem Solving
Leibniz's Stepped Reckoned
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• Jacquard Powerloom
• 1801
• weave automatically
• Programs punched in cards
• read from punched wooden cards
CSEG1003 Programming for Problem Solving
Jacquards Loom
CSEG1003 Programming for Problem Solving
Practical Jacquards Loom
CSEG1003 Programming for Problem Solving
Sample Punch card
CSEG1003 Programming for Problem Solving
• Differential Engine
• Charles Babbage – Father of Computers
• English Mathematician
• 1822
• First Computer
• Basic calc+ Log + Differential equation
• Steam Driven machine
• Single Stored program in Memory
• Memory + Central Processing Unit
• Punch Cards as memory
Steps……..Inventions
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• Analytical Engine
• Charles Babbage
• 1833
• Fully functional
• differential engine
• Contains
• Input device as cards
• Control unit
• Output device
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Steps…Inventions
• Hollerith Tabulator
• Herman Hollerith
• 1889
• U.S Census Bureau
• Official Purpose
• Punch cards
• store data
• Used Electricity
• Later IBM
• Mainframe+OS
• OS/2 -> OS with
windows
CSEG1003 Programming for Problem Solving
Memory Tapes
CSEG1003 Programming for Problem Solving
MainFrame Computers – 1955 - US
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• Mark 1
• 1944
• IBM + Harvard Aiken
• Replaces the mechanical component
• Relays
• Electro magnetic component
• ENIAC
• 1946
• John Eckert and John Mauchly
• Electronic Numerical Integrator And Calculator
• Electronic Vaccum Tubes
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• EDVAC
• Electronic Discrete Variable Automatic Computer
• John Eckert and John Mauchly
• Capability to stop and resume
• EDSAC
• Electronic Delay Storage Automatic Calculator
• 1949
• Maurice Wilkes
• Mercury delay lines – memory
• Vacuum tubes --- logic
CSEG1003 Programming for Problem Solving
Steps……..Inventions
• UNIVAC
• Universal Automatic Compute
• 1951
• Beginning of computer era
• John Eckert and John Mauchly
• 1970
• Integrated Circuits
• Replaces vaccum tubes
• 1980
• Very Large Scale Integration (VLSI)
CSEG1003 Programming for Problem Solving
Mini Comp. ---Apple1 -- $600 ---1976
CSEG1003 Programming for Problem Solving
IBM PC ---- 1990
CSEG1003 Programming for Problem Solving
Apple II
CSEG1003 Programming for Problem Solving
GENERATION OF
COMPUTERS
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem Solving
First Generation
• 1940 – 1956
• Vaccum Tubes
• Machine Language
• Specification
• Vacuum tubes -> circuitry
• Magnetic drums -> memory
• Input ->punched cards and paper tape
• Output ->printouts
• Examples
• UNIVAC -U.S. Census Bureau in 1951
• ENIAC computers
• Disadvantage
• Expensive
• Huge conception of electricity
• Big & Clumsy
• Air conditioning Necessary
• Non portable
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Second Generation
• 1956 - 1963
• Transistor
• used to relay and switch electronic signals
• Assembly language
• Specification
• punched cards for input
• printouts for output
• Transistor for circuits
• magnetic core technology for memory
• Computers smaller, faster, cheaper, portable and
more energy-efficient and need air conditioning.
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Third Generations
• 1964 – 1970
• Integrated Circuits
• Transistors were miniaturized and placed on silicon chips called
semiconductors
• High Level Language
• Specifications
• Keyboard as input
• Monitor as output
• Operating System
• Central program that controls the devices
• Advantages
• Speed
• Efficiency
• Portable
• Cheap
• Less power
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Fourth Generation
• 1970 – Present
• Data Communication
• Microprocessors
• thousands of integrated circuits were built onto a single silicon chip
• Properties
• Instruction set
• Bandwidth
• Clock Speed
• Example
• Intel 4004 chip – minuscule chip(cpu+ memory+ i/p+ o/p unit)
• 1984 Apple introduced the Macintosh
• Specification
• Microprocessor
• Mouse and other handheld devices
• CPU and ALU
• RAID – Redundant array of Independent Disk for memory
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Fifth Generation
• Present and Beyond
• Artificial Intelligence
• Game Playing
• Expert System
• Robotics
• Mega chips
• Parallel processing
• Voice Recognition
• Example
• No fully AI computers
• 1997, an IBM super-computer called Deep Blue defeated world
chess champion Gary Kasparov in a chess
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
CLASSIFICATION OF
COMPUTERS
CSEG1003 Programming for Problem
Solving
Classification of Computers
Types of Computers
On the basis of
Purpose
Special
Purpose
General
Purpose
On the basis of Technology
Analog
Digital
Hybrid
On the basis of Size &
Capacity
Super
Main Frame
Mini
Micro
CSEG1003 Programming for Problem Solving
Super Computers
CSEG1003 Programming for Problem Solving
Main Frame Computer
CSEG1003 Programming for Problem Solving
Mini Computers
CSEG1003 Programming for Problem Solving
Micro Computers
CSEG1003 Programming for Problem Solving
Generation of Programming Languages
CSEG1003 Programming for Problem Solving
Next Lecture #2…….Online Lecture
•Organization of Computers
• Hardware
• Input Unit
• Output Unit
• Storage Unit
• Processing Unit
• Software
• System Software
• Application Software
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
LECTURE #3
NUMBER SYSTEM CONVERSION PROBLEMS
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
Why number system conversion problems
• For digital hardware, the natural numbering system is
binary (base 2).
• Expressing anything in binary causes way too many bits
to be used
• hexadecimal allows us to use 4x fewer bits, so, it is very
useful.
CSEG1003 Programming for Problem Solving
Two Major classifications
• Non positional Number System
• Roman Numbering (………I,II,III,IV……..)
• Collection of symbols
• Counting the figures
• Difficult with large numbers
• Positional Number System
• Uses digits instead of symbols
• Digits positions are accounted
• 3 terminology
• Digit (set of symbols)
• Position of digit (LSB, MSB, unit, tens, hundred…)
• Base or radix(total no of digits)
CSEG1003 Programming for Problem Solving
Decimal Number System
• Base 10
• Valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Position
• unit
• ten
• hundred
• thousand
CSEG1003 Programming for Problem Solving
Binary Number System
• Base 2
• Valid digits - 0, 1
• Position
• least significant bit(LSB)
• most significant bit(MSB)
CSEG1003 Programming for Problem Solving
Octal Number System
• Base 8
• Valid digits - 0, 1, 2, 3, 4, 5, 6, 7
• Position
• least significant bit(LSB)
• most significant bit(MSB)
CSEG1003 Programming for Problem Solving
HexaDecimal Number System
• Base 16
• valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
• A refers to decimal 10, B refers to decimal 11, etc.
• Fig. The list of digits in each Number System
CSEG1003 Programming for Problem Solving
Decimal to < Binary|Octal|HexaDecimal >
CSEG1003 Programming for Problem Solving
Contd.
CSEG1003 Programming for Problem Solving
Contd.
CSEG1003 Programming for Problem Solving
< Binary|Octal|HexaDecimal > to Decimal
CSEG1003 Programming for Problem Solving
Some more conversions
CSEG1003 Programming for Problem Solving
Activity
Binary Decimal Octal HexaDecimal
6E7
92
12A
1010100101
745
679
1010101000
320
CSEG1003 Programming for Problem Solving
Pseudocode
• Writing the Pseudocode
• Pseudocode means an imitation computer code.
• It is used in place of symbols or a flowchart to describe
the logic of a program. Thus, it is a set of instructions
(descriptive form) to describe the logic of a program.
• Pseudocode is close to the actual programming
language.
• Using the Pseudocode, the programmer can start to
write the actual code.
CSEG1003 Programming for Problem Solving
Lecture #4 Online Lecture
• Problem Solving Techniques
• Need for Logical Thinking and Design
• Algorithm
• Flowchart
• Psedocode
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
LECTURE #5
PROBLEM SOLVING TECHNIQUES &
LOGICALANALYSISAND THINKING
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
How to solve a problem?
• Programming is a problem-solving activity.
• Problem-solving methods are covered in many subject
areas:
• Business students learn to solve problems with a systems approach
• Engineering and Science students use the engineering and science
methods
• Programmers use the Software Development Method
Software Development Method
Execute & Test
Finally, the program is tested to verify that it behaves as intended.
Coding -------Write Program with some Programming Language
C C++ Java ….
Modify the solution if necessary
Check it
Analysis & Design Plan It
algorithm flowchart pseudocode
PreProgrammingSteps
CSEG1003 Programming for Problem Solving
Introduction to Algorithms
• The algorithm is the abstract idea of solving a problem.
• The algorithm is written in user language
CSEG1003 Programming for Problem Solving
Algorithms vs. programs
• When an algorithm is coded using any programming
language (e.g. C++), then it is called a program.
• The program is a set of instructions that can run by the
computer.
CSEG1003 Programming for Problem Solving
• The algorithm would consist of at least the
following tasks:
1- Input (Read the data)
2- Processing (Perform the computation)
3- Output (Display the results)
CSEG1003 Programming for Problem Solving
Example 1
• Write a algorithm to find an area of a circle where area = pi
* radius * radius
Data Processing Output
radius area = 3.14 x radius x radius area
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Flowchart
• It is another way to display the algorithm.
• Diagram representation –
• special geometric symbols connected by lines and contain
the instructions.
CSEG1003 Programming for Problem Solving
Flowchart Symbols
Symbol Function
Show the direction of data flow or logical
solution.
Indicate the beginning and ending of a set of
actions or instructions (logical flow) of a module
or program.
Indicate a process, such as calculations,
opening and closing files.
CSEG1003 Programming for Problem Solving
Indicate input to the program and output from the
program.
Use for making decision. Either True or False based
on certain condition.
Use for doing a repetition or looping of certain steps.
Connection of flowchart on the same page.
Connection of flowchart from page to page.
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Structuring a Program
• Develop efficient computer solution to problems:
1. Use Modules
2. Use four logic structures
a. Sequential structure
• Executes instructions one after another in a sequence.
b. Decision structure
• Branches to execute one of two possible sets of instructions.
c. Loop structure
• Executes set of instruction many times.
d. Case structure
• Executes one set of instructions out of several sets.
3. Eliminate rewriting of identical process by using modules.
4. Use techniques to improve readability including four logic
structure, proper naming of variables, internal documentation
and proper indentation.
CSEG1003 Programming for Problem Solving
Sequential Logic Structure
CSEG1003 Programming for Problem Solving
The Decision Logic Structure
• Implements using the IF/THEN/ELSE instruction.
• Tells the computer that IF a condition is true, THEN
execute a set of instructions, or ELSE execute another set
of instructions
• ELSE part is optional, as there is not always a set of
instructions if the conditions are false.
• Algorithm:
IF <condition(s)> THEN
<TRUE instruction(s)>
ELSE
<FALSE instruction(s)
CSEG1003 Programming for Problem Solving
Decision Logic Structure
CSEG1003 Programming for Problem Solving
Example:1
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
The Loop Logic Structure
• Repeat structure
• To solve the problem that doing the same task over and
over for different sets of data
• Types of loop:
• WHILE loop
• Do..WHILE loop
• Automatic-Counter Loop
CSEG1003 Programming for Problem Solving
Loop Logic Structure
CSEG1003 Programming for Problem Solving
Examples
CSEG1003 Programming for Problem Solving
The Case Logic Structure
• Made up of several or many sets of instructions, only one
of which will be selected by the user and executed by the
computer
• Algorithm:
CASE OF VARIABLE
= constant1:
actions for VARIABLE = constant1
= constants2:
actions for VARIABLE = constant2
…
OTHERWISE:
Actions for VARIABLE = anything else
END-OF-CASE
CSEG1003 Programming for Problem Solving
Case Logic Structure
CSEG1003 Programming for Problem Solving
Example: Biggest of 3 numbers
CSEG1003 Programming for Problem Solving
Pseudocode
• Pseudocode means an imitation computer code.
• Pseudocode is close to the actual programming
language.
• Using the Pseudocode, the programmer can start
to write the actual code.
• Psedocode Programming Constructs includes
• READ, PRINT, SET , INITIALIZE
• INCREMENT,DECREMENT,
• IF…THEN….ENDIF,IF….THEN….ELSE….ENDIF,
• REPEAT ….UNTILL, DO…WHILE
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Example 2 : Sum of 5 numbers
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving

More Related Content

What's hot (19)

Introduction to HDLs
Introduction to HDLsIntroduction to HDLs
Introduction to HDLs
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
 
c++
 c++  c++
c++
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Functional programming-advantages
Functional programming-advantagesFunctional programming-advantages
Functional programming-advantages
 
Mit6 087 iap10_lec02
Mit6 087 iap10_lec02Mit6 087 iap10_lec02
Mit6 087 iap10_lec02
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
C language
C languageC language
C language
 
Syntaxdirected
SyntaxdirectedSyntaxdirected
Syntaxdirected
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
 
C++
C++C++
C++
 
Clanguage
ClanguageClanguage
Clanguage
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Ocs752 unit 1
Ocs752   unit 1Ocs752   unit 1
Ocs752 unit 1
 

Similar to Programming for Problem Solving Unit 1

CSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to ComputersCSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to ComputersDhiviya Rose
 
VLSI and ES Design -An Overview.pptx
VLSI and ES Design -An Overview.pptxVLSI and ES Design -An Overview.pptx
VLSI and ES Design -An Overview.pptxNukalaMurthy1
 
Introduction To Computing (Evolution of Computers)
Introduction To Computing (Evolution of Computers) Introduction To Computing (Evolution of Computers)
Introduction To Computing (Evolution of Computers) Mian Zain Latif
 
Unit 1 Business Computing
Unit 1 Business ComputingUnit 1 Business Computing
Unit 1 Business ComputingDhiviya Rose
 
Introduction to Digital Electronics & What we will study.ppt
Introduction to Digital Electronics & What we will study.pptIntroduction to Digital Electronics & What we will study.ppt
Introduction to Digital Electronics & What we will study.pptGauravKumarDas5
 
Sistem mikroprosessor
Sistem mikroprosessorSistem mikroprosessor
Sistem mikroprosessorfahmihafid
 
arquitectura_de_las_pc.pdf
arquitectura_de_las_pc.pdfarquitectura_de_las_pc.pdf
arquitectura_de_las_pc.pdfbrydyl
 
COMPUTER SCIENCE CLASS 11
COMPUTER SCIENCE CLASS 11COMPUTER SCIENCE CLASS 11
COMPUTER SCIENCE CLASS 11Aditi Bhushan
 
Advanced data structures & algorithms important questions
Advanced data structures & algorithms important questionsAdvanced data structures & algorithms important questions
Advanced data structures & algorithms important questionsselvaraniArunkumar
 
Module 1 intro to computng science
Module 1 intro to computng scienceModule 1 intro to computng science
Module 1 intro to computng sciencemiemzzy
 
Unit1-fcp-fundamentals of computing
Unit1-fcp-fundamentals of computingUnit1-fcp-fundamentals of computing
Unit1-fcp-fundamentals of computingkokilabe
 
What is Computer | Computer Full Form | Computer Definition
What is Computer | Computer Full Form | Computer DefinitionWhat is Computer | Computer Full Form | Computer Definition
What is Computer | Computer Full Form | Computer Definitiondmir3304
 
Bsc cs 1 fit u-1 computer hardware system
Bsc cs 1 fit u-1 computer hardware systemBsc cs 1 fit u-1 computer hardware system
Bsc cs 1 fit u-1 computer hardware systemRai University
 

Similar to Programming for Problem Solving Unit 1 (20)

CSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to ComputersCSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to Computers
 
VLSI and ES Design -An Overview.pptx
VLSI and ES Design -An Overview.pptxVLSI and ES Design -An Overview.pptx
VLSI and ES Design -An Overview.pptx
 
Introduction To Computing (Evolution of Computers)
Introduction To Computing (Evolution of Computers) Introduction To Computing (Evolution of Computers)
Introduction To Computing (Evolution of Computers)
 
Unit 1 Business Computing
Unit 1 Business ComputingUnit 1 Business Computing
Unit 1 Business Computing
 
Introduction to Digital Electronics & What we will study.ppt
Introduction to Digital Electronics & What we will study.pptIntroduction to Digital Electronics & What we will study.ppt
Introduction to Digital Electronics & What we will study.ppt
 
SPC Unit 1
SPC Unit 1SPC Unit 1
SPC Unit 1
 
aca mod1.pptx
aca mod1.pptxaca mod1.pptx
aca mod1.pptx
 
Computing through the ages
Computing through the agesComputing through the ages
Computing through the ages
 
Sistem mikroprosessor
Sistem mikroprosessorSistem mikroprosessor
Sistem mikroprosessor
 
Chap003
Chap003Chap003
Chap003
 
arquitectura_de_las_pc.pdf
arquitectura_de_las_pc.pdfarquitectura_de_las_pc.pdf
arquitectura_de_las_pc.pdf
 
COMPUTER SCIENCE CLASS 11
COMPUTER SCIENCE CLASS 11COMPUTER SCIENCE CLASS 11
COMPUTER SCIENCE CLASS 11
 
Advanced data structures & algorithms important questions
Advanced data structures & algorithms important questionsAdvanced data structures & algorithms important questions
Advanced data structures & algorithms important questions
 
Basic Computer 2018 part _1
Basic Computer 2018 part _1Basic Computer 2018 part _1
Basic Computer 2018 part _1
 
Processors selection
Processors selectionProcessors selection
Processors selection
 
Module 1 intro to computng science
Module 1 intro to computng scienceModule 1 intro to computng science
Module 1 intro to computng science
 
Unit1-fcp-fundamentals of computing
Unit1-fcp-fundamentals of computingUnit1-fcp-fundamentals of computing
Unit1-fcp-fundamentals of computing
 
What is Computer | Computer Full Form | Computer Definition
What is Computer | Computer Full Form | Computer DefinitionWhat is Computer | Computer Full Form | Computer Definition
What is Computer | Computer Full Form | Computer Definition
 
Bsc cs 1 fit u-1 computer hardware system
Bsc cs 1 fit u-1 computer hardware systemBsc cs 1 fit u-1 computer hardware system
Bsc cs 1 fit u-1 computer hardware system
 
Micro controller & Micro processor
Micro controller & Micro processorMicro controller & Micro processor
Micro controller & Micro processor
 

More from Dhiviya Rose

Module 3 microsoft powerpoint
Module 3 microsoft powerpointModule 3 microsoft powerpoint
Module 3 microsoft powerpointDhiviya Rose
 
Module 3 business computing.pdf
Module 3 business computing.pdfModule 3 business computing.pdf
Module 3 business computing.pdfDhiviya Rose
 
Module 2 Digital Devices and its Applications
Module 2 Digital Devices and its ApplicationsModule 2 Digital Devices and its Applications
Module 2 Digital Devices and its ApplicationsDhiviya Rose
 
Module 1 - Digital Devices and its Application
Module 1 - Digital Devices and its ApplicationModule 1 - Digital Devices and its Application
Module 1 - Digital Devices and its ApplicationDhiviya Rose
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsDhiviya Rose
 
CSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and PointersCSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and PointersDhiviya Rose
 
CSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and UnionsCSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and UnionsDhiviya Rose
 
CSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming FundamentalsCSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming FundamentalsDhiviya Rose
 
Lecture 3 internet and web
Lecture 3 internet and webLecture 3 internet and web
Lecture 3 internet and webDhiviya Rose
 
Multidimentional array
Multidimentional arrayMultidimentional array
Multidimentional arrayDhiviya Rose
 
Searching in Arrays
Searching in ArraysSearching in Arrays
Searching in ArraysDhiviya Rose
 

More from Dhiviya Rose (13)

Module 3 microsoft powerpoint
Module 3 microsoft powerpointModule 3 microsoft powerpoint
Module 3 microsoft powerpoint
 
Module 3 business computing.pdf
Module 3 business computing.pdfModule 3 business computing.pdf
Module 3 business computing.pdf
 
Module 2 Digital Devices and its Applications
Module 2 Digital Devices and its ApplicationsModule 2 Digital Devices and its Applications
Module 2 Digital Devices and its Applications
 
Software
SoftwareSoftware
Software
 
Module 1 - Digital Devices and its Application
Module 1 - Digital Devices and its ApplicationModule 1 - Digital Devices and its Application
Module 1 - Digital Devices and its Application
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
 
CSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and PointersCSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and Pointers
 
CSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and UnionsCSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and Unions
 
CSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming FundamentalsCSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming Fundamentals
 
Lecture 3 internet and web
Lecture 3 internet and webLecture 3 internet and web
Lecture 3 internet and web
 
Strings
StringsStrings
Strings
 
Multidimentional array
Multidimentional arrayMultidimentional array
Multidimentional array
 
Searching in Arrays
Searching in ArraysSearching in Arrays
Searching in Arrays
 

Recently uploaded

Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectErbil Polytechnic University
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 

Recently uploaded (20)

Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction Project
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 

Programming for Problem Solving Unit 1

  • 1. CSEG1003 Programming for Problem Solving
  • 2. CSEG 1003 Programming for Problem Solving Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 3. Road Map • Generations of Computers and Languages • Organization of Computers • Number Systems Conversion • Logical Analysis and Thinking Introduction • Structure of C Program & Compilation and Linking Process • Variables and Datatypes • Managing Input and Output statements • Decision and Looping Statements C Programming Basics • Creation and Usages • 1D and 2 D arrys • String Functions • Matrix operations Arrays and Strings • Declaration and Definitions of Functions • Passing Arguments • Recursion • Pointers & Pointer Arithmetic Functions and Pointers • Need of Structure and Unions • Declaration and Definition • Storage classes • Preprocessor Directives Structures and Unions CSEG1003 Programming for Problem Solving
  • 4. LECTURE #1 EVOLUTION ,GENERATION OF COMPUTERS & CLASSIFICATION OF COMPUTERS Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 5. History • Abacus • Sliding Beads on a rack • Counting purpose • Operators on addition and subtraction • 300 B.C. • Napier Bones • Logarithmic value carved on ivory sticks • Scotsman ->John Napier • 1617 CSEG1003 Programming for Problem Solving
  • 6. Abacus – Addition and Subtraction CSEG1003 Programming for Problem Solving
  • 7. Napier’s Bones - Multiplication CSEG1003 Programming for Problem Solving
  • 8. Steps……..Inventions • Pascaline Machine • Functional Automatic Calculator • French Mathematician • Blaise Pascal • 1642 • gear-driven calculating machine • Eight movable dials CSEG1003 Programming for Problem Solving
  • 9. Gear Engine CSEG1003 Programming for Problem Solving
  • 10. CSEG1003 Programming for Problem Solving
  • 11. Steps……..Inventions • Leibniz's Stepped Reckoner • 1694 • German Mathemacian • addition, subtraction, multiplication, and division • Jacquard Powerloom • 1801 • weave automatically • read from punched wooden cards CSEG1003 Programming for Problem Solving
  • 12. Leibniz's Stepped Reckoned CSEG1003 Programming for Problem Solving
  • 13. Steps……..Inventions • Jacquard Powerloom • 1801 • weave automatically • Programs punched in cards • read from punched wooden cards CSEG1003 Programming for Problem Solving
  • 14. Jacquards Loom CSEG1003 Programming for Problem Solving
  • 15. Practical Jacquards Loom CSEG1003 Programming for Problem Solving
  • 16. Sample Punch card CSEG1003 Programming for Problem Solving
  • 17. • Differential Engine • Charles Babbage – Father of Computers • English Mathematician • 1822 • First Computer • Basic calc+ Log + Differential equation • Steam Driven machine • Single Stored program in Memory • Memory + Central Processing Unit • Punch Cards as memory Steps……..Inventions CSEG1003 Programming for Problem Solving
  • 18. Steps……..Inventions • Analytical Engine • Charles Babbage • 1833 • Fully functional • differential engine • Contains • Input device as cards • Control unit • Output device CSEG1003 Programming for Problem Solving
  • 19. CSEG1003 Programming for Problem Solving
  • 20. Steps…Inventions • Hollerith Tabulator • Herman Hollerith • 1889 • U.S Census Bureau • Official Purpose • Punch cards • store data • Used Electricity • Later IBM • Mainframe+OS • OS/2 -> OS with windows CSEG1003 Programming for Problem Solving
  • 21. Memory Tapes CSEG1003 Programming for Problem Solving
  • 22. MainFrame Computers – 1955 - US CSEG1003 Programming for Problem Solving
  • 23. Steps……..Inventions • Mark 1 • 1944 • IBM + Harvard Aiken • Replaces the mechanical component • Relays • Electro magnetic component • ENIAC • 1946 • John Eckert and John Mauchly • Electronic Numerical Integrator And Calculator • Electronic Vaccum Tubes CSEG1003 Programming for Problem Solving
  • 24. Steps……..Inventions • EDVAC • Electronic Discrete Variable Automatic Computer • John Eckert and John Mauchly • Capability to stop and resume • EDSAC • Electronic Delay Storage Automatic Calculator • 1949 • Maurice Wilkes • Mercury delay lines – memory • Vacuum tubes --- logic CSEG1003 Programming for Problem Solving
  • 25. Steps……..Inventions • UNIVAC • Universal Automatic Compute • 1951 • Beginning of computer era • John Eckert and John Mauchly • 1970 • Integrated Circuits • Replaces vaccum tubes • 1980 • Very Large Scale Integration (VLSI) CSEG1003 Programming for Problem Solving
  • 26. Mini Comp. ---Apple1 -- $600 ---1976 CSEG1003 Programming for Problem Solving
  • 27. IBM PC ---- 1990 CSEG1003 Programming for Problem Solving
  • 28. Apple II CSEG1003 Programming for Problem Solving
  • 30. CSEG1003 Programming for Problem Solving
  • 31. First Generation • 1940 – 1956 • Vaccum Tubes • Machine Language • Specification • Vacuum tubes -> circuitry • Magnetic drums -> memory • Input ->punched cards and paper tape • Output ->printouts • Examples • UNIVAC -U.S. Census Bureau in 1951 • ENIAC computers • Disadvantage • Expensive • Huge conception of electricity • Big & Clumsy • Air conditioning Necessary • Non portable CSEG1003 Programming for Problem Solving
  • 32. CSEG1003 Programming for Problem Solving
  • 33. Second Generation • 1956 - 1963 • Transistor • used to relay and switch electronic signals • Assembly language • Specification • punched cards for input • printouts for output • Transistor for circuits • magnetic core technology for memory • Computers smaller, faster, cheaper, portable and more energy-efficient and need air conditioning. CSEG1003 Programming for Problem Solving
  • 34. CSEG1003 Programming for Problem Solving
  • 35. Third Generations • 1964 – 1970 • Integrated Circuits • Transistors were miniaturized and placed on silicon chips called semiconductors • High Level Language • Specifications • Keyboard as input • Monitor as output • Operating System • Central program that controls the devices • Advantages • Speed • Efficiency • Portable • Cheap • Less power CSEG1003 Programming for Problem Solving
  • 36. CSEG1003 Programming for Problem Solving
  • 37. Fourth Generation • 1970 – Present • Data Communication • Microprocessors • thousands of integrated circuits were built onto a single silicon chip • Properties • Instruction set • Bandwidth • Clock Speed • Example • Intel 4004 chip – minuscule chip(cpu+ memory+ i/p+ o/p unit) • 1984 Apple introduced the Macintosh • Specification • Microprocessor • Mouse and other handheld devices • CPU and ALU • RAID – Redundant array of Independent Disk for memory CSEG1003 Programming for Problem Solving
  • 38. CSEG1003 Programming for Problem Solving
  • 39. Fifth Generation • Present and Beyond • Artificial Intelligence • Game Playing • Expert System • Robotics • Mega chips • Parallel processing • Voice Recognition • Example • No fully AI computers • 1997, an IBM super-computer called Deep Blue defeated world chess champion Gary Kasparov in a chess CSEG1003 Programming for Problem Solving
  • 40. CSEG1003 Programming for Problem Solving
  • 42. Classification of Computers Types of Computers On the basis of Purpose Special Purpose General Purpose On the basis of Technology Analog Digital Hybrid On the basis of Size & Capacity Super Main Frame Mini Micro CSEG1003 Programming for Problem Solving
  • 44. Main Frame Computer CSEG1003 Programming for Problem Solving
  • 45. Mini Computers CSEG1003 Programming for Problem Solving
  • 47. Generation of Programming Languages CSEG1003 Programming for Problem Solving
  • 48. Next Lecture #2…….Online Lecture •Organization of Computers • Hardware • Input Unit • Output Unit • Storage Unit • Processing Unit • Software • System Software • Application Software CSEG1003 Programming for Problem Solving
  • 49. CSEG1003 Programming for Problem Solving
  • 50. LECTURE #3 NUMBER SYSTEM CONVERSION PROBLEMS Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 51. Why number system conversion problems • For digital hardware, the natural numbering system is binary (base 2). • Expressing anything in binary causes way too many bits to be used • hexadecimal allows us to use 4x fewer bits, so, it is very useful. CSEG1003 Programming for Problem Solving
  • 52. Two Major classifications • Non positional Number System • Roman Numbering (………I,II,III,IV……..) • Collection of symbols • Counting the figures • Difficult with large numbers • Positional Number System • Uses digits instead of symbols • Digits positions are accounted • 3 terminology • Digit (set of symbols) • Position of digit (LSB, MSB, unit, tens, hundred…) • Base or radix(total no of digits) CSEG1003 Programming for Problem Solving
  • 53. Decimal Number System • Base 10 • Valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • Position • unit • ten • hundred • thousand CSEG1003 Programming for Problem Solving
  • 54. Binary Number System • Base 2 • Valid digits - 0, 1 • Position • least significant bit(LSB) • most significant bit(MSB) CSEG1003 Programming for Problem Solving
  • 55. Octal Number System • Base 8 • Valid digits - 0, 1, 2, 3, 4, 5, 6, 7 • Position • least significant bit(LSB) • most significant bit(MSB) CSEG1003 Programming for Problem Solving
  • 56. HexaDecimal Number System • Base 16 • valid digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • A refers to decimal 10, B refers to decimal 11, etc. • Fig. The list of digits in each Number System CSEG1003 Programming for Problem Solving
  • 57. Decimal to < Binary|Octal|HexaDecimal > CSEG1003 Programming for Problem Solving
  • 60. < Binary|Octal|HexaDecimal > to Decimal CSEG1003 Programming for Problem Solving
  • 61. Some more conversions CSEG1003 Programming for Problem Solving
  • 62. Activity Binary Decimal Octal HexaDecimal 6E7 92 12A 1010100101 745 679 1010101000 320 CSEG1003 Programming for Problem Solving
  • 63. Pseudocode • Writing the Pseudocode • Pseudocode means an imitation computer code. • It is used in place of symbols or a flowchart to describe the logic of a program. Thus, it is a set of instructions (descriptive form) to describe the logic of a program. • Pseudocode is close to the actual programming language. • Using the Pseudocode, the programmer can start to write the actual code. CSEG1003 Programming for Problem Solving
  • 64. Lecture #4 Online Lecture • Problem Solving Techniques • Need for Logical Thinking and Design • Algorithm • Flowchart • Psedocode CSEG1003 Programming for Problem Solving
  • 65. CSEG1003 Programming for Problem Solving
  • 66. LECTURE #5 PROBLEM SOLVING TECHNIQUES & LOGICALANALYSISAND THINKING Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 67. How to solve a problem? • Programming is a problem-solving activity. • Problem-solving methods are covered in many subject areas: • Business students learn to solve problems with a systems approach • Engineering and Science students use the engineering and science methods • Programmers use the Software Development Method
  • 68. Software Development Method Execute & Test Finally, the program is tested to verify that it behaves as intended. Coding -------Write Program with some Programming Language C C++ Java …. Modify the solution if necessary Check it Analysis & Design Plan It algorithm flowchart pseudocode PreProgrammingSteps CSEG1003 Programming for Problem Solving
  • 69. Introduction to Algorithms • The algorithm is the abstract idea of solving a problem. • The algorithm is written in user language CSEG1003 Programming for Problem Solving
  • 70. Algorithms vs. programs • When an algorithm is coded using any programming language (e.g. C++), then it is called a program. • The program is a set of instructions that can run by the computer. CSEG1003 Programming for Problem Solving
  • 71. • The algorithm would consist of at least the following tasks: 1- Input (Read the data) 2- Processing (Perform the computation) 3- Output (Display the results) CSEG1003 Programming for Problem Solving
  • 72. Example 1 • Write a algorithm to find an area of a circle where area = pi * radius * radius Data Processing Output radius area = 3.14 x radius x radius area CSEG1003 Programming for Problem Solving
  • 73. CSEG1003 Programming for Problem Solving
  • 74. Flowchart • It is another way to display the algorithm. • Diagram representation – • special geometric symbols connected by lines and contain the instructions. CSEG1003 Programming for Problem Solving
  • 75. Flowchart Symbols Symbol Function Show the direction of data flow or logical solution. Indicate the beginning and ending of a set of actions or instructions (logical flow) of a module or program. Indicate a process, such as calculations, opening and closing files. CSEG1003 Programming for Problem Solving
  • 76. Indicate input to the program and output from the program. Use for making decision. Either True or False based on certain condition. Use for doing a repetition or looping of certain steps. Connection of flowchart on the same page. Connection of flowchart from page to page. CSEG1003 Programming for Problem Solving
  • 77. CSEG1003 Programming for Problem Solving
  • 78. Structuring a Program • Develop efficient computer solution to problems: 1. Use Modules 2. Use four logic structures a. Sequential structure • Executes instructions one after another in a sequence. b. Decision structure • Branches to execute one of two possible sets of instructions. c. Loop structure • Executes set of instruction many times. d. Case structure • Executes one set of instructions out of several sets. 3. Eliminate rewriting of identical process by using modules. 4. Use techniques to improve readability including four logic structure, proper naming of variables, internal documentation and proper indentation. CSEG1003 Programming for Problem Solving
  • 79. Sequential Logic Structure CSEG1003 Programming for Problem Solving
  • 80. The Decision Logic Structure • Implements using the IF/THEN/ELSE instruction. • Tells the computer that IF a condition is true, THEN execute a set of instructions, or ELSE execute another set of instructions • ELSE part is optional, as there is not always a set of instructions if the conditions are false. • Algorithm: IF <condition(s)> THEN <TRUE instruction(s)> ELSE <FALSE instruction(s) CSEG1003 Programming for Problem Solving
  • 81. Decision Logic Structure CSEG1003 Programming for Problem Solving
  • 83. CSEG1003 Programming for Problem Solving
  • 84. The Loop Logic Structure • Repeat structure • To solve the problem that doing the same task over and over for different sets of data • Types of loop: • WHILE loop • Do..WHILE loop • Automatic-Counter Loop CSEG1003 Programming for Problem Solving
  • 85. Loop Logic Structure CSEG1003 Programming for Problem Solving
  • 87. The Case Logic Structure • Made up of several or many sets of instructions, only one of which will be selected by the user and executed by the computer • Algorithm: CASE OF VARIABLE = constant1: actions for VARIABLE = constant1 = constants2: actions for VARIABLE = constant2 … OTHERWISE: Actions for VARIABLE = anything else END-OF-CASE CSEG1003 Programming for Problem Solving
  • 88. Case Logic Structure CSEG1003 Programming for Problem Solving
  • 89. Example: Biggest of 3 numbers CSEG1003 Programming for Problem Solving
  • 90. Pseudocode • Pseudocode means an imitation computer code. • Pseudocode is close to the actual programming language. • Using the Pseudocode, the programmer can start to write the actual code. • Psedocode Programming Constructs includes • READ, PRINT, SET , INITIALIZE • INCREMENT,DECREMENT, • IF…THEN….ENDIF,IF….THEN….ELSE….ENDIF, • REPEAT ….UNTILL, DO…WHILE CSEG1003 Programming for Problem Solving
  • 91. CSEG1003 Programming for Problem Solving
  • 92. Example 2 : Sum of 5 numbers CSEG1003 Programming for Problem Solving
  • 93. CSEG1003 Programming for Problem Solving