SlideShare a Scribd company logo
XP
1
C-PROGRAMMING
UNIT 1: PROBLEM SOLVING USING COMPUTER
Presented By:
Er.Ganesh Ram Suwal
BE | ME Computer Engineering
Email: suwalganesh@gmail.com
Lecturer
January 2015
XP
2
INTRODUCTION
 If any problem is solved by using computer, then that is called
Problem Solving using Computer.
Problem Solving Using Computer
1. Problem Definition, Problem Statement
2. Problem Analysis
3. Algorithm Development & Flowcharting
4. Coding
5. Compilation & Execution
6. Debugging & Testing
7. Program Documentation
XP
3
Problem Definition and Analysis
1. What is a Problem ?
 Problem is defined as the difference between an existing situation and a
desired situation.
 A problem is numerical situation and has complex form
 Solution is desired situation and has simplest form.
 First, you should know the behavior, nature or type of problem. In order to
get exact solution,
 you must analyze the problem.
XP
4
ALGORITHM
 Algorithm is a step-by-step procedure to solve the problem.
 An algorithm is a sequence of instructions designed in such a way
that if the instructions are executed in the specified sequence, the
desired result will be obtained.
XP
5
CHARACTERISTICS OF ALGORITHM
1. Each and every instruction should be precise and unambiguous.
2. Well defined inputs and well defined Outputs
3. Each instruction should be such that it can be performed in a finite
time.
4. Instructions should not be repeated infinitely. This ensures that the
algorithm will ultimately terminate.
5. After performing the instructions, that is after the algorithm
terminates, the desire for results must be obtained.
6. Programming Language Independent
7. Algorithm Should be Effectiveness and Feasible
(Summary: Inputs, Outputs, Definiteness, Correctness, Finiteness,
Effectiveness, Generality and Efficient)
XP
6
EXAMPLE OF ALGORITHM
Write an algorithm for checking odd and even. The number is entered
by a user.
Step1: Read a number from user
Step2: Divide the entered number by 2 and check the remainder
If the remainder is 0,
Print the given number is even
Else
Print the given number is odd
Step3: Stop
XP
7
FLOWCHART
 A flowchart is a pictorial representation of an algorithm that uses
different shapes to denote different types of instructions.
 The actual instructions are written within these boxes using clear
and concise statements. These boxes are connected by solid lines
having arrow marks to indicate the flow of operation, that is, the
exact sequence in which the instructions are to be executed.
 The flowchart is a roadmap to solve a problem.
XP
8
SYMBOLS USED IN FLOWCHART
 Terminal: Used to represent start and end of a flowchart. It is also
used to pauses (HALT) in the program logic flow. It is the first symbol
and last symbol in the program logic. Oval Shape or elliptical Shape
 Input/output: Used to make input/output in the program.
For e.g. read data from user and display message in display unit.
Parallelogram Shape
Fig 1: Terminals
Fig 2: Input/Output
XP
9
SYMBOLS USED IN FLOWCHART
 Processing: It is used to represent arithmetic and data movement
instructions. Arithmetic processes are of adding, subtracting,
multiplying and dividing are shown by a processing symbol.
Rectangle Shape
 Flowlines: The normal flow of flowchart is from top to bottom and left
to right. Arrowheads are required only when the normal top to bottom
flow is not to be followed. Good practice also dictates that flow lines
should not cross each other and that such intersections should be
avoided whenever possible.
Fig 3: Processing
Fig 4: Flow Lines
XP
10
SYMBOLS USED IN FLOWCHART
 Decision: The decision symbol is used in a flowchart to indicate a point
at which a decision has to be made and a branch to one of two or
more alternative points is possible. The criteria for making the
decision should be indicated clearly within the decision box. Diamond
Shape
 Connector: If a flowchart becomes very long, it is difficult to write in a
single page or the flowlines start crisscross at many places that causes
confusion and reduces understandability of the flowchart. In that case
we can use connectors. Small Circle with a small arrowhead line
Fig 5: Decision
Fig 6: Connectors
XP
11
FLOWCHART EXAMPLE
Fig 7: Flow chart for checking even number of Odd Number
XP
12
CODING
 Coding is the Computer
programming
 Coding is the process of
writing a program that is
understandable by
computer.
 Various programming
languages are used for
writing coding.
Fig 8: Various Programming Languages
XP
13
COMPILATION & EXECUTION
 Compilation is the process of converting the source codes (Program) of a
computer translated into machine codes.
 After compilation if everything is ok, the code is going under other process that
is known as execution.
 We can get the required output after execution process.
XP
14
DEBUGGING & TESTING
 The process of finding and removing errors (also sometimes called bugs) from a
program is known as debugging.
 Once the location of an error is identified and the error is corrected, the
debugging statements may be removed.
Types of errors
1. Syntax errors
2. Logic errors
3. Run-time errors
1. Syntax errors
Syntax errors are those errors which are arise on violate the rules of programming
language.
If there is syntax error in the program, then the program will not be executing.
XP
15
DEBUGGING & TESTING
2. Logic errors
Logic errors are those which arise when programmers proceed the logic process in
wrong way or miss some statements.
It is difficult to debug such errors because the computer does not display them.
3. Run-Time Errors
Run-time errors are those which occur when programmers attempt to run ambiguous
instructions.
They occur due to infinite loop of statement, device errors (system out of memory),
software errors, etc.
Runtime errors are:
1.Divide by zero
2.Null pointer assignment
3.Data over flow
XP
16
PROGRAM DOCUMENTATION
 Program Documentations are the brief explanatory note on the
programmer’s program segment while writing program.
 This explanatory note is called comment. It explains how the program
works and interacts with it.
 Thus, it helps other programmers to understand the program.
Two Types of documentation:
1. Internal documentation – Comments in the Program
2. External documentation – File of a Program
XP
17
PROGRAMMING LANGUAGE
 A language which is use to give command to the computer is
known as programming language.
 A computer software is made using computer programming
language.
JAVA, C# dot net, VB dot net, ASP dot net, PHP, C, C++ etc are
the programming language.
The Programming languages are classified as
1. High Level Programming Language
2. Middle Level Programming Language
3. Low Level or Machine Level Programming Language
XP
18
PROGRAMMING LANGUAGE
Fig 9: Classification of Programming Languages
XP
19
1. LOW LEVEL PROGRAMMING LANGUAGE
 Low Level Programming languages are directly
understandable by a computer
 It is also called Machine level language and specific to a
computer hardware. So it is machine dependent or machine
codes.
 The low-level language is binary language (written in 0’s and
1’s form).
 Only the computer programmer or computer specelist
understand low level language.
 All the program written in high level or middle level language
must be converted into low level language for execution.
XP
20
2. MIDDLE LEVEL PROGRAMMING LANGUAGE
 Middle Level Language is also called Symbolic Language like
Assembly Language
 Various Symbols “mnemonics” are used in assembly
language. Example ADD for Addition, SUB for Subtraction
etc.
 It is little bit user-friendly than low level language but still it
is very difficult to understand by non programmers.
 Some middle level languages are machine dependent.
Fig 10: Assembler as Converter Program
XP
21
3. HIGH LEVEL PROGRAMMING LANGUAGE
 High Level language is very easy to understand by human
beings even by non programmers also.
 The popular high-level languages are FORTAN, COBOL,
BASIC, C, C++, JAVA etc.
 High level language uses English word like INPUT, OUTPUT,
PRINT etc.
 Computer don’t directly understand the high-level language
so it must be converted into computer understandable
format.
Fig 11: Compiler as Converter Program
XP
22
CONVERTER PROGRAM
 Program written in High level language or Middle level
languages are needed to convert into Machine level language.
Without Conversion, the program will not be executed.
 The converter programs are Compiler, Interpreter or
Assembler.
 As C-programming is middle level language so we need
compiler or Interpreter for program execution.
 Turbo C is a Compiler that converts C-program into machine
Program.
Fig 12: Converter Program
XP
23
CONVERTER PROGRAM
1. Assembler
It is a conversion program that converts Assembly language into
its corresponding machine level language.
E.g. MASAM
2. Interpreters
Interpreters are used for conversion of High-level language into
low level language.
Interpreter convert the program code line by line.
If any errors occur immediately, it will show the error message.
XP
24
CONVERTER PROGRAM
3. Compiler
Compilers are the translator program which is used for
conversion of High-Level Language into low level Language.
TURBO C is an example of compiler
Fig 13: Compiler Converter Source Program to Executable Codes
XP
25
Difference between Compiler & Interpreter
Compiler Interpreter
Compile all the program at a time Run line by line statement
Intermediate Code is generated No Intermediate code is generated
Conditional control Statements are
executing Faster
Conditional Control Statements are
executing slower
More Complex Program Less complex compared to Compiler
High Memory is Required Less Memory is required compared to
compiler
Program need not be compiled every
time
Every time higher level program is
converted into lower-level program
Errors are displayed after entire program
is checked
Errors are displayed for every instruction
interpreted
Example: C Compiler Example: BASIC
XP
26
for more remaining chapters mail to:
suwalganesh@gmail.com
Thank You
Ad

More Related Content

Similar to UNIT 1: Problem Solving Using Computer (20)

Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
Mukesh Tekwani
 
introduction to computing & programming
introduction to computing &  programmingintroduction to computing &  programming
introduction to computing & programming
Kalai Selvi
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
smkengkilili2011
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
baabtra.com - No. 1 supplier of quality freshers
 
Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2
Mohd Harris Ahmad Jaal
 
Computer
ComputerComputer
Computer
leeparkkim
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
TamiratDejene1
 
Introduction to programming language (basic)
Introduction to programming language (basic)Introduction to programming language (basic)
Introduction to programming language (basic)
nharsh2308
 
Structured programming Unit-1-Introduction-to-C-Programming.pptx
Structured programming Unit-1-Introduction-to-C-Programming.pptxStructured programming Unit-1-Introduction-to-C-Programming.pptx
Structured programming Unit-1-Introduction-to-C-Programming.pptx
SuryaBasnet1
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS12
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin
 
4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithms
hccit
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and Flowchart
Bom Khati
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answers
vithyanila
 
introduction to programming
introduction to programmingintroduction to programming
introduction to programming
Gaea Bonita
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
Mohit Saini
 
Algorithm to programs.pptx
Algorithm to programs.pptxAlgorithm to programs.pptx
Algorithm to programs.pptx
Chandansharma918351
 
Sec 1 in programming like programming fund
Sec 1 in programming like programming fundSec 1 in programming like programming fund
Sec 1 in programming like programming fund
engahmedeg94
 
C.pdf
C.pdfC.pdf
C.pdf
5reality786
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
meisaina
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
Mukesh Tekwani
 
introduction to computing & programming
introduction to computing &  programmingintroduction to computing &  programming
introduction to computing & programming
Kalai Selvi
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
smkengkilili2011
 
Introduction to programming language (basic)
Introduction to programming language (basic)Introduction to programming language (basic)
Introduction to programming language (basic)
nharsh2308
 
Structured programming Unit-1-Introduction-to-C-Programming.pptx
Structured programming Unit-1-Introduction-to-C-Programming.pptxStructured programming Unit-1-Introduction-to-C-Programming.pptx
Structured programming Unit-1-Introduction-to-C-Programming.pptx
SuryaBasnet1
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS12
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin
 
4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithms
hccit
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and Flowchart
Bom Khati
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answers
vithyanila
 
introduction to programming
introduction to programmingintroduction to programming
introduction to programming
Gaea Bonita
 
Sec 1 in programming like programming fund
Sec 1 in programming like programming fundSec 1 in programming like programming fund
Sec 1 in programming like programming fund
engahmedeg94
 

More from Er. Ganesh Ram Suwal (11)

Bubble Sort
Bubble SortBubble Sort
Bubble Sort
Er. Ganesh Ram Suwal
 
Tower of HANOI
Tower of HANOITower of HANOI
Tower of HANOI
Er. Ganesh Ram Suwal
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Er. Ganesh Ram Suwal
 
STACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LISTSTACK IMPLEMENTATION USING SINGLY LINKED LIST
STACK IMPLEMENTATION USING SINGLY LINKED LIST
Er. Ganesh Ram Suwal
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
Er. Ganesh Ram Suwal
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
Er. Ganesh Ram Suwal
 
Circular queue
Circular queueCircular queue
Circular queue
Er. Ganesh Ram Suwal
 
Linear queue
Linear queueLinear queue
Linear queue
Er. Ganesh Ram Suwal
 
Proposal Writing
Proposal WritingProposal Writing
Proposal Writing
Er. Ganesh Ram Suwal
 
DSA chapter 1
DSA chapter 1DSA chapter 1
DSA chapter 1
Er. Ganesh Ram Suwal
 
Web Technology And Its Scope in NEPAL.pptx
Web Technology And Its Scope in NEPAL.pptxWeb Technology And Its Scope in NEPAL.pptx
Web Technology And Its Scope in NEPAL.pptx
Er. Ganesh Ram Suwal
 
Ad

Recently uploaded (20)

hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Journal of Soft Computing in Civil Engineering
 
Control Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptxControl Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptx
vvsasane
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Physical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A ReviewPhysical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A Review
Journal of Soft Computing in Civil Engineering
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
Deepfake Phishing: A New Frontier in Cyber Threats
Deepfake Phishing: A New Frontier in Cyber ThreatsDeepfake Phishing: A New Frontier in Cyber Threats
Deepfake Phishing: A New Frontier in Cyber Threats
RaviKumar256934
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Control Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptxControl Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptx
vvsasane
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
Deepfake Phishing: A New Frontier in Cyber Threats
Deepfake Phishing: A New Frontier in Cyber ThreatsDeepfake Phishing: A New Frontier in Cyber Threats
Deepfake Phishing: A New Frontier in Cyber Threats
RaviKumar256934
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
Ad

UNIT 1: Problem Solving Using Computer

  • 1. XP 1 C-PROGRAMMING UNIT 1: PROBLEM SOLVING USING COMPUTER Presented By: Er.Ganesh Ram Suwal BE | ME Computer Engineering Email: suwalganesh@gmail.com Lecturer January 2015
  • 2. XP 2 INTRODUCTION  If any problem is solved by using computer, then that is called Problem Solving using Computer. Problem Solving Using Computer 1. Problem Definition, Problem Statement 2. Problem Analysis 3. Algorithm Development & Flowcharting 4. Coding 5. Compilation & Execution 6. Debugging & Testing 7. Program Documentation
  • 3. XP 3 Problem Definition and Analysis 1. What is a Problem ?  Problem is defined as the difference between an existing situation and a desired situation.  A problem is numerical situation and has complex form  Solution is desired situation and has simplest form.  First, you should know the behavior, nature or type of problem. In order to get exact solution,  you must analyze the problem.
  • 4. XP 4 ALGORITHM  Algorithm is a step-by-step procedure to solve the problem.  An algorithm is a sequence of instructions designed in such a way that if the instructions are executed in the specified sequence, the desired result will be obtained.
  • 5. XP 5 CHARACTERISTICS OF ALGORITHM 1. Each and every instruction should be precise and unambiguous. 2. Well defined inputs and well defined Outputs 3. Each instruction should be such that it can be performed in a finite time. 4. Instructions should not be repeated infinitely. This ensures that the algorithm will ultimately terminate. 5. After performing the instructions, that is after the algorithm terminates, the desire for results must be obtained. 6. Programming Language Independent 7. Algorithm Should be Effectiveness and Feasible (Summary: Inputs, Outputs, Definiteness, Correctness, Finiteness, Effectiveness, Generality and Efficient)
  • 6. XP 6 EXAMPLE OF ALGORITHM Write an algorithm for checking odd and even. The number is entered by a user. Step1: Read a number from user Step2: Divide the entered number by 2 and check the remainder If the remainder is 0, Print the given number is even Else Print the given number is odd Step3: Stop
  • 7. XP 7 FLOWCHART  A flowchart is a pictorial representation of an algorithm that uses different shapes to denote different types of instructions.  The actual instructions are written within these boxes using clear and concise statements. These boxes are connected by solid lines having arrow marks to indicate the flow of operation, that is, the exact sequence in which the instructions are to be executed.  The flowchart is a roadmap to solve a problem.
  • 8. XP 8 SYMBOLS USED IN FLOWCHART  Terminal: Used to represent start and end of a flowchart. It is also used to pauses (HALT) in the program logic flow. It is the first symbol and last symbol in the program logic. Oval Shape or elliptical Shape  Input/output: Used to make input/output in the program. For e.g. read data from user and display message in display unit. Parallelogram Shape Fig 1: Terminals Fig 2: Input/Output
  • 9. XP 9 SYMBOLS USED IN FLOWCHART  Processing: It is used to represent arithmetic and data movement instructions. Arithmetic processes are of adding, subtracting, multiplying and dividing are shown by a processing symbol. Rectangle Shape  Flowlines: The normal flow of flowchart is from top to bottom and left to right. Arrowheads are required only when the normal top to bottom flow is not to be followed. Good practice also dictates that flow lines should not cross each other and that such intersections should be avoided whenever possible. Fig 3: Processing Fig 4: Flow Lines
  • 10. XP 10 SYMBOLS USED IN FLOWCHART  Decision: The decision symbol is used in a flowchart to indicate a point at which a decision has to be made and a branch to one of two or more alternative points is possible. The criteria for making the decision should be indicated clearly within the decision box. Diamond Shape  Connector: If a flowchart becomes very long, it is difficult to write in a single page or the flowlines start crisscross at many places that causes confusion and reduces understandability of the flowchart. In that case we can use connectors. Small Circle with a small arrowhead line Fig 5: Decision Fig 6: Connectors
  • 11. XP 11 FLOWCHART EXAMPLE Fig 7: Flow chart for checking even number of Odd Number
  • 12. XP 12 CODING  Coding is the Computer programming  Coding is the process of writing a program that is understandable by computer.  Various programming languages are used for writing coding. Fig 8: Various Programming Languages
  • 13. XP 13 COMPILATION & EXECUTION  Compilation is the process of converting the source codes (Program) of a computer translated into machine codes.  After compilation if everything is ok, the code is going under other process that is known as execution.  We can get the required output after execution process.
  • 14. XP 14 DEBUGGING & TESTING  The process of finding and removing errors (also sometimes called bugs) from a program is known as debugging.  Once the location of an error is identified and the error is corrected, the debugging statements may be removed. Types of errors 1. Syntax errors 2. Logic errors 3. Run-time errors 1. Syntax errors Syntax errors are those errors which are arise on violate the rules of programming language. If there is syntax error in the program, then the program will not be executing.
  • 15. XP 15 DEBUGGING & TESTING 2. Logic errors Logic errors are those which arise when programmers proceed the logic process in wrong way or miss some statements. It is difficult to debug such errors because the computer does not display them. 3. Run-Time Errors Run-time errors are those which occur when programmers attempt to run ambiguous instructions. They occur due to infinite loop of statement, device errors (system out of memory), software errors, etc. Runtime errors are: 1.Divide by zero 2.Null pointer assignment 3.Data over flow
  • 16. XP 16 PROGRAM DOCUMENTATION  Program Documentations are the brief explanatory note on the programmer’s program segment while writing program.  This explanatory note is called comment. It explains how the program works and interacts with it.  Thus, it helps other programmers to understand the program. Two Types of documentation: 1. Internal documentation – Comments in the Program 2. External documentation – File of a Program
  • 17. XP 17 PROGRAMMING LANGUAGE  A language which is use to give command to the computer is known as programming language.  A computer software is made using computer programming language. JAVA, C# dot net, VB dot net, ASP dot net, PHP, C, C++ etc are the programming language. The Programming languages are classified as 1. High Level Programming Language 2. Middle Level Programming Language 3. Low Level or Machine Level Programming Language
  • 18. XP 18 PROGRAMMING LANGUAGE Fig 9: Classification of Programming Languages
  • 19. XP 19 1. LOW LEVEL PROGRAMMING LANGUAGE  Low Level Programming languages are directly understandable by a computer  It is also called Machine level language and specific to a computer hardware. So it is machine dependent or machine codes.  The low-level language is binary language (written in 0’s and 1’s form).  Only the computer programmer or computer specelist understand low level language.  All the program written in high level or middle level language must be converted into low level language for execution.
  • 20. XP 20 2. MIDDLE LEVEL PROGRAMMING LANGUAGE  Middle Level Language is also called Symbolic Language like Assembly Language  Various Symbols “mnemonics” are used in assembly language. Example ADD for Addition, SUB for Subtraction etc.  It is little bit user-friendly than low level language but still it is very difficult to understand by non programmers.  Some middle level languages are machine dependent. Fig 10: Assembler as Converter Program
  • 21. XP 21 3. HIGH LEVEL PROGRAMMING LANGUAGE  High Level language is very easy to understand by human beings even by non programmers also.  The popular high-level languages are FORTAN, COBOL, BASIC, C, C++, JAVA etc.  High level language uses English word like INPUT, OUTPUT, PRINT etc.  Computer don’t directly understand the high-level language so it must be converted into computer understandable format. Fig 11: Compiler as Converter Program
  • 22. XP 22 CONVERTER PROGRAM  Program written in High level language or Middle level languages are needed to convert into Machine level language. Without Conversion, the program will not be executed.  The converter programs are Compiler, Interpreter or Assembler.  As C-programming is middle level language so we need compiler or Interpreter for program execution.  Turbo C is a Compiler that converts C-program into machine Program. Fig 12: Converter Program
  • 23. XP 23 CONVERTER PROGRAM 1. Assembler It is a conversion program that converts Assembly language into its corresponding machine level language. E.g. MASAM 2. Interpreters Interpreters are used for conversion of High-level language into low level language. Interpreter convert the program code line by line. If any errors occur immediately, it will show the error message.
  • 24. XP 24 CONVERTER PROGRAM 3. Compiler Compilers are the translator program which is used for conversion of High-Level Language into low level Language. TURBO C is an example of compiler Fig 13: Compiler Converter Source Program to Executable Codes
  • 25. XP 25 Difference between Compiler & Interpreter Compiler Interpreter Compile all the program at a time Run line by line statement Intermediate Code is generated No Intermediate code is generated Conditional control Statements are executing Faster Conditional Control Statements are executing slower More Complex Program Less complex compared to Compiler High Memory is Required Less Memory is required compared to compiler Program need not be compiled every time Every time higher level program is converted into lower-level program Errors are displayed after entire program is checked Errors are displayed for every instruction interpreted Example: C Compiler Example: BASIC
  • 26. XP 26 for more remaining chapters mail to: suwalganesh@gmail.com Thank You
  翻译: