Lecture 1
Lecture 1
Lecture 1
Programming
LOGIC & PROBLEM SOLVING
Logic & Problem solving
• Enables the learner to approach real world problems in a
systematic manner, which is an essential skill for a software
engineer.
Types of Problems
Examples of Computational Problems
Exercise
1. What comes in your mind when you hear the word problem?
List down the different words that you have come across.
2. Then try to search the problems which you can completely
solve with computer.
Classification of computational problems
Exercise
• Make a list of different examples of computational problems
like
• Find out who was the topper of your class ( arrange in ascending
or descending order)
• Calculate the average score of your class
Distributed Example
Sequential/Event Based Example
Exercise: Lifecycle
Start
Print answer
Get 2 numbers
End
Add them
What are those funny symbols?
• START/END
• INPUT/OUTPUT
• PROCESS
• DECISION
What are those funny symbols?
• START/END
• Used at the beginning
and end of each
flowchart.
What are those funny symbols?
• INPUT/OUTPUT
• Shows when
information/data comes
into a program or is
printed out.
What are those funny symbols?
• PROCESS
• Used to show
calculations, storing of
data in variables, and
other “processes” that
take place within a
program.
What are those funny symbols?
• DECISION
• Used to show that the
program must decide Y
whether something X>7?
(usually a comparison
N
between numbers) is true
or false. YES and NO (or
T/F) branches are usually
shown.
Another Sample:
Calculating Age
• Pseudocode:
• Start
• Get year born
• Calculate age
• Print age
• If age > 50 print OLD
• End
Another Sample: Start
Calculating Age
• Flowchart Get yr
• Start
• Get year born Calc age
• Calculate age
• Print age Print age
• If age > 50 print OLD
• End OLD Y Age>50?
N
End
Steps to develop an Algorithm
Example
• Write an algorithm to find the average marks scored by a
student. Also check whether the student has passed or failed.
For a student to pass, the average marks secured should be
65.
What does the computer understand?
• Key Difference:
• A procedural programming language consists of a set of
procedure calls and a set of code for each procedure.
• A structural programming language emphasizes on separating a
program’s data from its functionality.
• object oriented languages are based on entities known as
objects.
Procedural Programming
Languages
• These languages code programs in such a way that the
program executes statement by statement, reading and
modifying a shared memory.
• statements are organized into procedures.
• These procedures are also known as subroutines or functions.
• It is written in a step by step manner, thus it is very easy to
follow the smaller programs.
• Example: C , Ada
Object oriented Languages:
• Object oriented program languages are based on the ‘objects’
rather than ‘actions’.
• This language gives more preference to data rather than logic.
An object can be defined as the pairing of a piece of data with
the operations that can be performed on it.
• It is one of the latest and powerful types.
• Objects are capable of storing information and they can also
interact with other objects.
Summary