SlideShare a Scribd company logo
2
Most read
20
Most read
23
Most read
CC-112
PROGRAMMING FUNDAMENTALS
Lecture No.1
Introduction To Problem Solving
Delivered By Aamir Shahzad
WHAT IS A PROGRAM ?
 A computer program is a set of computer instructions, which are
used for solving a problem. The program directs the computer to
perform the actions that are needed to arrive at a solution.
 The number of instructions required to solve a problem depends on
the complexity of the problem. These instructions may range from
a few to many hundreds or thousands.
 The computation might be something mathematical, such as
solving a system of equations or finding the roots of a polynomial.
 But it can also be a symbolic computation, such as searching and
replacing text in a document or (strangely enough) compiling a
program.
PROGRAMMING: A WAY OF THINKING
 Combines features from mathematics, engineering, and
natural science.
 Like mathematicians, computer scientists use formal
languages to denote ideas (specifically computations).
 Like engineers, they design things, assembling components
into systems and evaluating tradeoffs among alternatives.
 Like scientists, they observe the behavior of complex systems,
form hypotheses, and test predictions.
PROGRAMMING: A WAY OF THINKING
• The single most important skill for a computer scientist is
problem solving.
• Problem solving means:
• The ability to formulate problems, think creatively about solutions, and
express a solution clearly and accurately.
PROBLEMS? . . .
• The problem is not that there are problems. The problem is expecting
otherwise and thinking that having problems is a problem.“ Theodore Rubin
• The best way to escape from a problem is to solve it.--Brendan Francis
• Every problem contains within itself the seeds of its own solution.--Stanley
Arnold
• It isn't that they can't see the solution. It's that they can't see the problem.--
G. K. Chesterton
• Problems are to the mind what exercise is to the muscles, they toughen and
make strong. - Norman Vincent Peale
WHAT IS A PROBLEM (IN COMPUTING)
 A discrepancy between what is required and what exists.
 A computer program is meant to solve a problem.
 Think of a programming problem in the same light as you
would think of a mathematical problem. It's not something
bad(though some people may say otherwise).
 Rather, it is something that needs to be solved or a task that
needs to be accomplished.
WHAT IS PROBLEM SOLVING?
• Problem solving has long been recognized as one of the
hallmarks of mathematics.
• “Solving a problem means finding a way out of difficulty, a
way around an obstacle, attaining an aim which was not
immediately attainable.”
FOUR-STEP PROBLEM-SOLVING PROCESS
1. Understand the problem
2. Devise a plan
3. Carry out the plan
4. Look back
STEP-1: UNDERSTANDING THE PROBLEM
• Can you state the problem in your own words?
• What are you trying to find or do?
• What are the unknowns?
• What information do you obtain from the problem?
• What information, if any, is missing or not needed?
STEP-2: DEVISING A PLAN
(SOME STRATEGIES YOU MAY FIND USEFUL)
• Look for a pattern.
• Examine related problems and determine if the same technique can
be used.
• Examine a simpler problem to gain insight into the solution of the
original problem.
• Make a table or list.
• Make a diagram.
• Write an equation.
• Use guess and check.
• Work backward.
• Identify a subgoal.
• Use indirect reasoning.
• Use direct reasoning.
STEP-3: CARRYING OUT THE PLAN
• Implement the strategy or strategies.
• Check each step of the plan as you proceed.
• Keep an accurate record of your work.
• Implement the strategy of strategies in step 2 and perform
any necessary actions or computations.
• Check each step of the plan as you proceed. This may be
intuitive checking or a formal proof of each step.
• Keep an accurate record of your work. Label each step.
STEP-4: LOOKING BACK
CHECK THE RESULTS IN THE ORIGINAL PROBLEM
• Interpret the solution in terms of the original problem.
• Determine whether there is another method of finding the
solution.
• If possible, determine other related or more general problems
for which the techniques will work.
DEVELOPMENT OF COMPUTER SOLUTION
• Identify or Define the problem
• Analyze the problem in terms of inputs, outputs, formulas,
constants)
• Design the Solution
• Represent the most efficient solution in the form of an
algorithm.
• Implement (program coding)
• Evaluate
IDENTIFY OR DEFINE THE PROBLEM
 In order for you to come up with an algorithm to solve a
problem, you must first have a clear understanding of what
the problem is.
 The first thing you have to do is to obtain a problem
statement (a clear definition of the problem that needs to be
solved).
 At this level it will usually be provided for you, but in the real
world the programmer would have to work with his client to
come up with one.
 Here are some (very simple) examples of problem statements:
ANALYZE THE PROBLEM
 We need to read it till we understand every detail
 We need to dissect the problem into its component parts (e.g.
problems and sub-problems)
 We need to remove any ambiguity, extra information
 We need to determine our knowns and our unknowns
 We need to be aware of any assumptions we are making.
ANALYZE THE PROBLEM
The Program Must Read Two Numbers And Print The Total Of
The Two.
 Determining the input, output, processing and storage
 The next step in defining the problem is to break it down into
its main components:
1. Inputs - the data you are provided with or have to obtain from the
user. Some words that help you to identify the inputs are: read, input,
enter, given, accept
2. Outputs - the results that should be produced
3. Processing - the tasks that must be performed, i.e. what must be
done with the inputs to get the outputs
4. Storage - the data that must be stored
ANALYZE THE PROBLEM
The Program Must Read Two Numbers And Print The Total Of
The Two.
• Inputs - The word 'read' tells us that the inputs will be in the form of two
numbers. For reasons that will be explained later, it's helpful to give the
inputs names, so we'll call them numl and num2.
• Outputs - The desired result is the total, so we'll call the output 'total’.
• Processing - Reading the two numbers is processing and so is printing the
total. But is that everything? The total doesn't magically appear. You have
to do something to the inputs to obtain the total. So there is an in-
between step that is implied - calculating the total.
• Storage - the data that must be stored
ANALYZE THE PROBLEM
The Program Must Read Two Numbers And Print The Total Of
The Two.
• Defining diagrams
• One way of illustrating the main components of a problem is by using
a defining diagram.
• A defining diagram is a table with three columns: 'Input', 'Processing'
and 'Output'.
• Consider the following problem statement:
Write a program that reads two numbers and prints the total.
• Even this simple statement requires some detective work to figure out
the input, output and especially the processing.
• the defining diagram would look like this:
Input Processing Output
Two Numbers, i.e.
numl, num2
Read two numbers
Total
Calculate the total
Print the total
DESIGN THE SOLUTION
 Developing the algorithm that solves the
problem
 Identify alternative ways to solve the problem
 Select the best way to solve the problem from the list
of alternative solutions
 List instructions that enable you to solve the problem
using selected solution
 The algorithm is expressed a s flowchart or
pseudo-code
PAYROLL EXAMPLE - ANALYSIS
PAYROLL EXAMPLE - DESIGN
PROGRAM COMPONENTS
 A few basic instructions appear in every language:
 Input - Get data from the keyboard, a file, or some other device.
 Output - Display data on the screen or send data to a file or other
device.
 Math Perform basic mathematical operations like addition and
multiplication.
 Conditional execution - Check for certain conditions and execute
the appropriate sequence of statements.
 Repetition/Looping - Perform some action repeatedly, usually with
some variation.
WHAT IS DEBUGGING?
 Programming errors are called bugs and the process of tracking them down and
correcting them is called debugging.
 Three kinds of errors can occur in a program:
1. Syntax errors
 A program can only be executed if it is syntactically correct; otherwise, the process fails and returns an
error message.
 syntax refers to the structure of a program and the rules about that structure.
2. Runtime errors
 So called because the error does not appear until you run the program.
 These errors are also called exceptions because they usually indicate that something exceptional (and
bad) has happened.
3. Semantic errors
 If there is a semantic error in the program, it will run successfully, in the sense that the computer will
not generate any error messages, but it will not do the right thing. It will do something else.
Specifically, it will do what the programmer told it to do.
 But the written program does not solve the original problem. The meaning of the program (its
semantics) is wrong.

More Related Content

PPTX
Introduction.pptx
PPTX
PPS_Unit 1.pptx
PPTX
Introduction to Programming
PPTX
01 Programming Fundamentals.pptx
PPT
Computer Programming Computer Programming
PPTX
Unit no_1.pptx
PDF
Practical 01 (detailed)
PDF
Study Material for Problem Solving Techniques
Introduction.pptx
PPS_Unit 1.pptx
Introduction to Programming
01 Programming Fundamentals.pptx
Computer Programming Computer Programming
Unit no_1.pptx
Practical 01 (detailed)
Study Material for Problem Solving Techniques

Similar to CC-112-Lec.1.ppsx (20)

PPT
Unit 1 python (2021 r)
PPTX
Pj01 1-computer and programming fundamentals
PPTX
Introduction to problem solving Techniques
PPT
Data structures & problem solving unit 1 ppt
PPT
(Prog213) (introduction to programming)v1
PDF
Computer Science (CSC 102) Lecture 1.pdf
PPTX
what is Algorithm? how to solve a problem by using algorithm.pptx
PDF
01 - Introduction to Computer and Algorithm (1).pdf
PDF
Algorithm.pdf
PPTX
Algorithmic thinking with python Module 1.2
PPTX
Unit 2 CPR.pptxaccSSzzCSDVVSVZVZSVVSDVDDSDDS
PPTX
Enhanced_CT_Design_Thinking_Presentation (1).pptx
PPTX
Algorithm for computational problematic sit
DOCX
Chapter 2(1)
PPTX
Chp-1 DAA (2).pptx design analysis and algoritham presentation
PPTX
Power Point Introduction To Programming 1
PDF
Lecture 7 program development issues (supplementary)
PPTX
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
PPTX
Algorithm types performance steps working
DOCX
Csc 102 lecture note(introduction to problem solving)
Unit 1 python (2021 r)
Pj01 1-computer and programming fundamentals
Introduction to problem solving Techniques
Data structures & problem solving unit 1 ppt
(Prog213) (introduction to programming)v1
Computer Science (CSC 102) Lecture 1.pdf
what is Algorithm? how to solve a problem by using algorithm.pptx
01 - Introduction to Computer and Algorithm (1).pdf
Algorithm.pdf
Algorithmic thinking with python Module 1.2
Unit 2 CPR.pptxaccSSzzCSDVVSVZVZSVVSDVDDSDDS
Enhanced_CT_Design_Thinking_Presentation (1).pptx
Algorithm for computational problematic sit
Chapter 2(1)
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Power Point Introduction To Programming 1
Lecture 7 program development issues (supplementary)
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
Algorithm types performance steps working
Csc 102 lecture note(introduction to problem solving)
Ad

Recently uploaded (20)

PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPT
What is a Computer? Input Devices /output devices
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Getting Started with Data Integration: FME Form 101
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
Modernising the Digital Integration Hub
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
WOOl fibre morphology and structure.pdf for textiles
Developing a website for English-speaking practice to English as a foreign la...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Tartificialntelligence_presentation.pptx
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
Univ-Connecticut-ChatGPT-Presentaion.pdf
What is a Computer? Input Devices /output devices
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Enhancing emotion recognition model for a student engagement use case through...
cloud_computing_Infrastucture_as_cloud_p
Getting Started with Data Integration: FME Form 101
O2C Customer Invoices to Receipt V15A.pptx
Modernising the Digital Integration Hub
Hindi spoken digit analysis for native and non-native speakers
Group 1 Presentation -Planning and Decision Making .pptx
DP Operators-handbook-extract for the Mautical Institute
Module 1.ppt Iot fundamentals and Architecture
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
WOOl fibre morphology and structure.pdf for textiles
Ad

CC-112-Lec.1.ppsx

  • 1. CC-112 PROGRAMMING FUNDAMENTALS Lecture No.1 Introduction To Problem Solving Delivered By Aamir Shahzad
  • 2. WHAT IS A PROGRAM ?  A computer program is a set of computer instructions, which are used for solving a problem. The program directs the computer to perform the actions that are needed to arrive at a solution.  The number of instructions required to solve a problem depends on the complexity of the problem. These instructions may range from a few to many hundreds or thousands.  The computation might be something mathematical, such as solving a system of equations or finding the roots of a polynomial.  But it can also be a symbolic computation, such as searching and replacing text in a document or (strangely enough) compiling a program.
  • 3. PROGRAMMING: A WAY OF THINKING  Combines features from mathematics, engineering, and natural science.  Like mathematicians, computer scientists use formal languages to denote ideas (specifically computations).  Like engineers, they design things, assembling components into systems and evaluating tradeoffs among alternatives.  Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.
  • 4. PROGRAMMING: A WAY OF THINKING • The single most important skill for a computer scientist is problem solving. • Problem solving means: • The ability to formulate problems, think creatively about solutions, and express a solution clearly and accurately.
  • 5. PROBLEMS? . . . • The problem is not that there are problems. The problem is expecting otherwise and thinking that having problems is a problem.“ Theodore Rubin • The best way to escape from a problem is to solve it.--Brendan Francis • Every problem contains within itself the seeds of its own solution.--Stanley Arnold • It isn't that they can't see the solution. It's that they can't see the problem.-- G. K. Chesterton • Problems are to the mind what exercise is to the muscles, they toughen and make strong. - Norman Vincent Peale
  • 6. WHAT IS A PROBLEM (IN COMPUTING)  A discrepancy between what is required and what exists.  A computer program is meant to solve a problem.  Think of a programming problem in the same light as you would think of a mathematical problem. It's not something bad(though some people may say otherwise).  Rather, it is something that needs to be solved or a task that needs to be accomplished.
  • 7. WHAT IS PROBLEM SOLVING? • Problem solving has long been recognized as one of the hallmarks of mathematics. • “Solving a problem means finding a way out of difficulty, a way around an obstacle, attaining an aim which was not immediately attainable.”
  • 8. FOUR-STEP PROBLEM-SOLVING PROCESS 1. Understand the problem 2. Devise a plan 3. Carry out the plan 4. Look back
  • 9. STEP-1: UNDERSTANDING THE PROBLEM • Can you state the problem in your own words? • What are you trying to find or do? • What are the unknowns? • What information do you obtain from the problem? • What information, if any, is missing or not needed?
  • 10. STEP-2: DEVISING A PLAN (SOME STRATEGIES YOU MAY FIND USEFUL) • Look for a pattern. • Examine related problems and determine if the same technique can be used. • Examine a simpler problem to gain insight into the solution of the original problem. • Make a table or list. • Make a diagram. • Write an equation. • Use guess and check. • Work backward. • Identify a subgoal. • Use indirect reasoning. • Use direct reasoning.
  • 11. STEP-3: CARRYING OUT THE PLAN • Implement the strategy or strategies. • Check each step of the plan as you proceed. • Keep an accurate record of your work. • Implement the strategy of strategies in step 2 and perform any necessary actions or computations. • Check each step of the plan as you proceed. This may be intuitive checking or a formal proof of each step. • Keep an accurate record of your work. Label each step.
  • 12. STEP-4: LOOKING BACK CHECK THE RESULTS IN THE ORIGINAL PROBLEM • Interpret the solution in terms of the original problem. • Determine whether there is another method of finding the solution. • If possible, determine other related or more general problems for which the techniques will work.
  • 13. DEVELOPMENT OF COMPUTER SOLUTION • Identify or Define the problem • Analyze the problem in terms of inputs, outputs, formulas, constants) • Design the Solution • Represent the most efficient solution in the form of an algorithm. • Implement (program coding) • Evaluate
  • 14. IDENTIFY OR DEFINE THE PROBLEM  In order for you to come up with an algorithm to solve a problem, you must first have a clear understanding of what the problem is.  The first thing you have to do is to obtain a problem statement (a clear definition of the problem that needs to be solved).  At this level it will usually be provided for you, but in the real world the programmer would have to work with his client to come up with one.  Here are some (very simple) examples of problem statements:
  • 15. ANALYZE THE PROBLEM  We need to read it till we understand every detail  We need to dissect the problem into its component parts (e.g. problems and sub-problems)  We need to remove any ambiguity, extra information  We need to determine our knowns and our unknowns  We need to be aware of any assumptions we are making.
  • 16. ANALYZE THE PROBLEM The Program Must Read Two Numbers And Print The Total Of The Two.  Determining the input, output, processing and storage  The next step in defining the problem is to break it down into its main components: 1. Inputs - the data you are provided with or have to obtain from the user. Some words that help you to identify the inputs are: read, input, enter, given, accept 2. Outputs - the results that should be produced 3. Processing - the tasks that must be performed, i.e. what must be done with the inputs to get the outputs 4. Storage - the data that must be stored
  • 17. ANALYZE THE PROBLEM The Program Must Read Two Numbers And Print The Total Of The Two. • Inputs - The word 'read' tells us that the inputs will be in the form of two numbers. For reasons that will be explained later, it's helpful to give the inputs names, so we'll call them numl and num2. • Outputs - The desired result is the total, so we'll call the output 'total’. • Processing - Reading the two numbers is processing and so is printing the total. But is that everything? The total doesn't magically appear. You have to do something to the inputs to obtain the total. So there is an in- between step that is implied - calculating the total. • Storage - the data that must be stored
  • 18. ANALYZE THE PROBLEM The Program Must Read Two Numbers And Print The Total Of The Two. • Defining diagrams • One way of illustrating the main components of a problem is by using a defining diagram. • A defining diagram is a table with three columns: 'Input', 'Processing' and 'Output'. • Consider the following problem statement: Write a program that reads two numbers and prints the total. • Even this simple statement requires some detective work to figure out the input, output and especially the processing. • the defining diagram would look like this: Input Processing Output Two Numbers, i.e. numl, num2 Read two numbers Total Calculate the total Print the total
  • 19. DESIGN THE SOLUTION  Developing the algorithm that solves the problem  Identify alternative ways to solve the problem  Select the best way to solve the problem from the list of alternative solutions  List instructions that enable you to solve the problem using selected solution  The algorithm is expressed a s flowchart or pseudo-code
  • 20. PAYROLL EXAMPLE - ANALYSIS
  • 22. PROGRAM COMPONENTS  A few basic instructions appear in every language:  Input - Get data from the keyboard, a file, or some other device.  Output - Display data on the screen or send data to a file or other device.  Math Perform basic mathematical operations like addition and multiplication.  Conditional execution - Check for certain conditions and execute the appropriate sequence of statements.  Repetition/Looping - Perform some action repeatedly, usually with some variation.
  • 23. WHAT IS DEBUGGING?  Programming errors are called bugs and the process of tracking them down and correcting them is called debugging.  Three kinds of errors can occur in a program: 1. Syntax errors  A program can only be executed if it is syntactically correct; otherwise, the process fails and returns an error message.  syntax refers to the structure of a program and the rules about that structure. 2. Runtime errors  So called because the error does not appear until you run the program.  These errors are also called exceptions because they usually indicate that something exceptional (and bad) has happened. 3. Semantic errors  If there is a semantic error in the program, it will run successfully, in the sense that the computer will not generate any error messages, but it will not do the right thing. It will do something else. Specifically, it will do what the programmer told it to do.  But the written program does not solve the original problem. The meaning of the program (its semantics) is wrong.