Sunteți pe pagina 1din 18

Programming Fundamentals

(CS118)
Week – 01
Aug 19-24, 2019
Instructor: Basit Ali
Chapter 1: General Problem - Solving Concepts
Course Outline
❖ Problem modeling, Algorithm analysis, Basic Flowchart and block diagram
❖ Data Types, Basic programming with algorithm, flow chart.
❖ Control structures: if-else, nested-if
❖ Switch case, Loops: For, While, do-while
❖ Nested loop, Functions
❖ Introduction to Array(1- dimensional)
❖ Multiple subscripted arrays and strings
❖ Introduction to Pointers, Pointers to array and double pointers.
❖ Dynamic Memory Allocation, Pointers functions and void pointers
❖ Introduction to Structures, Structure array and pointer to structures
❖ Union and Bitwise operators
❖ File Processing
❖ File Processing(Binary and Text files), Revision(structures, Pointers, Arrays)
Objectives
❖ Getting acquainted with problem understanding, modeling and
solving.
❖ Understanding the concept of Programming Languages.
❖ Two major areas to be covered:
● Computation and problem solving
● Implementation in C language.
❖ Design and implement algorithms to solve real world problems.
Books
1) “Problem Solving, Programming concepts”, 9th edition,
Sprankle and Hubbard
2) “How to Program C” , 7th edition, Deitel & Deitel

Reference Books:
1) “Let us C”, 5th edition, Yashavant P. Kanetkar.
Assessments / Grading (Tentative)

Mid-1 10
Mid-2 10
Quizzes 10
Assignments 10
Project 10
Final Exam 50
Chapter 1

General Problem - Solving concepts


Overview

❖ Problem Solving in Everyday Life


❖ Types of Problems
❖ Problem Solving with Computers
❖ Difficulties with Problem Solving
Problem Solving in Everyday Life

Six Steps of Problem Solving


The problem of what to do this evening

2. Understand the
problem 3. Identify alternatives
Consider the knowledge a. Watch television.
base of the participants . b. Invite friends over.
1. Identify the problem.
Select solutions that c. Play video games.
How do the individuals everyone involved would
wish to spend the know how to do. d. Go to the movies.
evening? e. Play miniature golf.
a game of chess, if the
participants did not know f. Go to the amusement
how to play. park.
g. Go to a friend’s party.
The problem of what to do this evening
4. Select the best way to
solve the problem. 5. Prepare a list of steps 6. Evaluate the solution.
a. Weed out alternatives that
are not acceptable, such as (instructions) that will Are we having fun yet?
those that cost too much result in a fun evening.
If nobody is having fun,
money or do not interest one
then replan.
of the individuals involved.
See if anything can be
b. Specify the pros and cons of
changed, if not then the
each remaining alternative.
process must start again.
c. Weigh the pros and cons to
make the final decision
Types of problems
Problems with algorithmic solutions

❖ Can be solved in a number of steps e.g. balancing a


checkbook.

❖ Algorithm: A number of steps that may be performed


repeatedly to reach some solution
Algorithm for going to the market to purchase
a pen

itself a complete task and separate


algorithm can be written for it
Problems with heuristic solutions

❖ Solutions that cannot be reached through a direct set of steps are called
heuristic solutions.

❖ These solutions require reasoning built on knowledge and experience,


and a process of trial and error.

❖ Example: how to buy the best stock or whether to expand the company
Problem solving with computers
Computer Problem solving

❖ Best for Algorithmic solution


➢ Calculating the monthly salary for employees

❖ Not so good for Heuristic solution

❖ E.g. the problem of how to throw a ball or how to speak English


➢ Artificial intelligence enables a computer to do things like build its own knowledge
bank and speak in a human language.
Difficulties in problem solving

❖ Poor training
The problem-solving process is not
❖ Afraid to make decisions
easy.
It takes practice and time to perfect
❖ Incorrect problem definition

❖ Inadequate steps of algorithm


Point to Ponder!!!!
• When solving problems on the computer, most difficult tasks is writing the
instructions.

• Exercise: task of deciding which number is


the largest from a group of three numbers
• Almost anyone can immediately tell which is the largest, but many cannot explain the steps they followed to arrive at it.

S-ar putea să vă placă și