SlideShare a Scribd company logo
Basic Programming Concept
Introduction
▪ Computer programs are the collections of instructions that
tell a computer what to do, how to interact with the user,
interact with the computer hardware and process data.
▪ The first programmable computers required the
programmers to write explicit (clear & exact) instructions to
directly manipulate the hardware of the computer.
2
Computer Programs
❖Computer programs, known as software. You tell a computer
what to do through programs.
❖Without programs, a computer is an empty machine.
❖Computers do not understand human languages, so you need to
use computer languages to communicate with them.
3
Programming Languages
⚫ Programs are written using programming
languages.
⚫ Programming language is an agreed upon
format of symbols that allow a programmer to
instruct a computer to perform certain
predefined tasks.
4
Types of programming languages
Some types of programming languages are:
⚫ Machine languages
⚫ Assembly languages
⚫ High-level languages
5
Machine language
⚫ Low-Level language is the only language which can
be understood by the computer.
⚫ Low-level language is also known as Machine
Language.
⚫ Sometimes called machine code or object code
⚫ The machine language contains only two symbols 1
& 0. All the instructions of machine language are
written in the form of binary numbers 1's & 0's.
⚫ A computer can directly understand the machine
language.
6
Assembly language
⚫ Middle-level language in which the instructions
are created using symbols such as letters, digits
and special characters.
⚫ In assembly language, we use predefined words
called mnemonics. Binary code instructions in
low-level language are replaced with mnemonics
and operands in middle-level language.
⚫ But the computer cannot understand mnemonics,
so we use a translator called Assembler to
translate mnemonics into machine language.
7
Assembly language (cont.)
⚫ Assembler is a translator which takes
assembly code as input and produces machine
code as output.
⚫ That means, the computer cannot understand
middle-level language, so it needs to be
translated into a low-level language to make it
understandable by the computer.
⚫ Assembler is used to translate middle-level
language into low-level language.
8
High-level languages
⮚High-level language is a computer language which
can be understood by the users.
⮚ The high-level language is very similar to human
languages and has a set of grammar rules that are
used to make instructions more easily.
⮚Every high-level language has a set of predefined
words known as Keywords and a set of rules
known as Syntax to create instructions.
9
High-level languages (Contd..)
⮚The high-level language is easier to understand
for the users but the computer can not
understand it.
⮚ High-level language needs to be converted into
the low-level language to make it understandable
by the computer.
⮚We use Compiler or interpreter to convert
high-level language to low-level language.
10
Examples of High-Level Languages
Java (An object oriented language). General purpose –
gaining popularity rapidly.
COBOL (Common Business Oriented Language).
Developed for business applications.
FORTRAN (FORmula TRANslation). Developed for
Engineering & Scientific Applications.
BASIC (Beginner All-purpose Symbolic Instructional
Code).
11
Examples of High-Level Languages (cont.)
⚫ C is designed to support only procedure-oriented
programming. Popular language for developing
system applications such as operating system and
compilers.
⚫ C++ is extension of C programming language that
supports object-oriented programming and procedure
oriented approach. General purpose and most popular.
⚫ Visual Basic – Basic-like visual language developed by
Microsoft.
12
Examples of High-Level Languages (cont.)
⚫ PROLOG - is a language for PROgramming in LOGic.
Artificial Intelligence.
⚫ Ada (named after Ada Lovelace)
⚫ Python - is a general purpose programming language
that's used to do things from testing microchips at
Intel, to building video games.
13
The Programming Process
Programming involves five steps to develop a
program.
1. Defining the problem: State the problem clearly.
2. Describe the input and output information.
3. Work the problem by hand (or with a calculator)
for a specific set of data.
4. Develop a solution that is general in nature.
5. Testing the program: Test the solution with a
variety of data sets.
14
Why Programming?
⚫ There are some good reasons for learning programming:
⚫ Computer programming can be used to create
innovative and functional software. Computer
programmers can use their creativity to design software
that will be useful to people, or that will improve the
way that people work.
⚫ Computers can also be programmed to perform specific
tasks using mathematical algorithms and logic.
⚫ It can also be used to create websites, games, and other
digital content.
15
Different Phases of Programming Task
A typical programming task can be divided into
three phases:
1) Pre-programming phase (or Problem Solving Phase)
• Produce an ordered sequence of steps that describe
solution of problem.
• Algorithms as well as Flowcharts are implemented in
problem solving phase of programming.
2) Programming phase(or Implementation Phase)
⚫ implement the program in some programming
language
3) Maintenance Phase
⚫ Maintain/modify to meet changed requirements or
to correct errors.
16
This phase requires four steps:
⮚Analyzing the problem.
⮚Developing the Input-Process-Output
(IPO) Chart.
⮚Writing the algorithm.
⮚Drawing the flowchart.
Pre-Programming Phase
17
Analyzing the problem
❖Understand and analyze the requirements of the
problem.
❖Identify the following:
⚫ Data requirement.
⚫ Processing requirement or procedures that will be needed to solve
the problem.
⚫ The output.
18
All these requirements can be presented in a Problem
Analysis Chart (PAC) as follows:
Data Processing Output
Given in
the
problem or
provided
by the user
List of
processing
required or
procedures
Output/
desired result
19
Problem 1: Calculate the salary of an employee who
works by hourly basis. The formula to be used is:
Salary = Hour works * Pay rate
Data Processing Output
Hours work,
Pay rate
Salary =
Hours works
* pay rate
Salary
20
Problem 2: Draw a Problem Analysis Chart (PAC) to
find the area of circle where area = pi * radius * radius
Data Processing Output
radius area = 3.14
x radius x
radius
area
21
Problem 3. Draw a problem analysis chart to convert
the distance in miles to kilometers where 1.609 per
mile.
Data Processing Output
Distance
in miles
Kilometers
= 1.609 x
miles
Distance in
kilometers
22
Problem 4. Draw a problem analysis chart to find
the area of a triangle.
Problem 5: Draw a problem analysis chart to
evaluate the following expression.
EXP= a²+2ab+b²
23
• Extends and organizes the information in the PAC.
• It shows in more details what items are input, what to
be processed and what will be the result or output.
Developing the Input-Process-Output (IPO)
Chart
24
Problem 1. Develop an IPO chart to convert the distance
in miles to kilometers where 1.609 kilometers per mile.
Input Processing Output
Distance in
miles
-Enter
distance
-Kilometers
= 1.609 x
miles
-Display
kilometers
-Distance in
kilometers
25
26
Constant and Variable
Constant: A constant can be defined as a fixed value,
which is used in algebraic expressions and equations. A
constant does not change over time and has a fixed
value. For example, the size of a shoe or cloth or any
apparel will not change at any point.
Variables: Variables are terms which can change or vary
over time. Its value does not remain constant, unlike
constants. For example, the height and weight of a
person do not always remain constant, and hence they
are variables.
❖In computer programming terms, an algorithm
is a set of well-defined instructions to solve a
particular problem.
❖It takes a set of input(s) and produces the
desired output.
❖Before writing a program, a programmer must
start with an algorithm of the program
following with flowchart and pseudo code.
❖Purpose: Algorithms provide a better
understanding towards programming and helps
in building better problem-solving logic.
Algorithms help the programmer to write code
faster by following steps in Algorithm.
What is algorithm?
27
❖It is not the entire program or code; it is simple logic to a
problem represented as an informal description in the form of a
flowchart or pseudo code.
What is algorithm? (contd..)
28
❖Problem: A problem can be defined as a real-world problem for which you
need to develop a program or set of instructions. An algorithm is a set of
instructions.
❖Algorithm: An algorithm is defined as a step-by-step process that will be
designed for a problem.
❖Input: After designing an algorithm, the algorithm is given the necessary
and desired inputs.
❖Processing unit: The input will be passed to the processing unit, producing
the desired output.
❖Output: The outcome or result of the program is referred to as the output.
What is algorithm? (Contd..)
29
Examples of Algorithm
Problem 1. Write an algorithm to “Make
Tea”
Algorithm
Step1. Start.
Step2. Take water in pan
Step3. Boil the water
Step4. Add sugar and Tea leaves
Step5. Add milk
Step6. Boil it
Step7. Pour it into cup
Step8. Stop
30
There may be more than one way to solve a problem,
so there may be more than one algorithm for a
problem.
Before writing an algorithm for a problem, one should
find out what is/are the inputs to the algorithm and
what is/are expected output after running the
algorithm.
31
While writing algorithms we will use following
symbols for different operations:
+ for Addition
- for Subtraction
* for Multiplication
/ for Division and
for assignment. For example
A X*3 means A will have a value of X*3.
32
⮚ Input: An algorithm requires some input values. An algorithm can be given a value
other than 0 as input.
⮚ Output: At the end of an algorithm, you will have one or more outcomes.
⮚ Unambiguity: A perfect algorithm is defined as unambiguous, which means that its
instructions should be clear and straightforward.
⮚ Finiteness: An algorithm must be finite. Finiteness in this context means that the
algorithm should have a limited number of instructions, i.e., the instructions should
be countable.
⮚ Effectiveness: Because each instruction in an algorithm affects the overall process,
it should be acceptable.
⮚ Language independence: An algorithm must be language-independent, which
means that its instructions can be implemented in any language and produce the same
results.
The essential properties of
Algorithm are:
33
Steps for Developing an Algorithm
✔Define the problem: State the problem you are trying to solve
in clear and concise terms.
✔List the inputs (information needed to solve the problem) and
the outputs (what the algorithm will produce as a result)
✔Describe the steps needed to convert or manipulate the inputs
to produce the outputs. keep refining the steps until they are
effectively computable operations.
✔Test the algorithm: choose data sets and verify that your
algorithm works!
34
Examples of Algorithm
Problem 2: Find the area of a Circle of radius r.
Algorithm:
Step1: Start
Step2: Readinput the Radius r of the Circle
Step3: Area PI*r*r // calculation of area
Step4: Print Area
Step5: Stop
35
Problem 3: Write an algorithm and draw a flow chart
to read two numbers and find their sum.
Algorithm:
Step 1 : Start
Step 2 : Input first number A
Step 3 : Input second number B
Step 4 : Total = A+B
Step 5 : Print Total
Step 6 : Stop
36
Practice Algorithm
✔Algorithm 1: Find the largest number between
two numbers
✔Algorithm 2: Find the odd and even number
from a given input value.
37
Flowchart
◆ A flowchart is simply a graphical representation of steps. It
shows steps in sequential order and is widely used in
presenting the flow of algorithms, workflow or processes.
◆ Typically, a flowchart shows the steps as boxes of various
kinds, and their order by connecting them with arrows.
◆ Flowcharts are very helpful in writing programs and explaining
them to others.
◆ Flowcharts are quite helpful in understanding the logic of
complicated and lengthy problems.
◆ Once the flowchart is drawn, it becomes easy to write the
program in any programming language.
38
When to use a flowchart?
★ It is most importantly used when the programmers
make projects. As a flowchart is a basic step to make
the design of projects.
★ When the flowcharts of a process are drawn, the
programmer understands the non-useful parts of the
process. So flowcharts are used to separate useful logic
from the unwanted parts.
★ Since the rules and procedure of drawing a flowchart
are universal, flowchart serves as a communication
channel to the people who are working on the same
project for better understanding.
39
BASIC FLOWCHART SYMBOLS ARE
GIVEN IN THE NEXT SLIDE
40
Symbol Name Use in flowcharts
Start/Stop
(Oval)
Denotes the beginning or end of
the program
Flow line Show the direction of data flow
or logical solution
Process
(Rectangle)
Indicates a process to be carried
out such as addition, subtraction,
multiplication and division.
Input/Output
(Parallelogram)
Indicates input to the program or
output from the program
41
Symbol Name Use in flowcharts
Question,
Decision
(Diamond)
Used for making a decision. The
program should continue along one of
two routes; either true or false based
on certain conditions.
Connector
(Circle)
Connection of flowchart on the same
page.
Connector Connection of flowchart from one
page to another.
42
1. Use conventional flowchart symbols. Each symbol should
have one exit point except the decision symbol. As far as
possible each symbol should also have one entry point and
in the case of decision symbol, it is a must.
2. The flow of control in the problem can be shown with the
help of arrows. But, the flow lines should not cross each
other.
3. The processing logic within the flowchart should flow from
top to bottom and from left to right.
4. The instructions written within the various flowchart
symbols should be independent of programming languages.
General Rules for flowcharting
43
5. The flow lines coming out of the decision symbol
should be properly labelled.
6. If the flowchart becomes large and complex (on same
page) then make use of ordinary connector symbols to
avoid crossing of flow lines.
7. Every flow chart must have the start and End points.
44
General Rules for flowcharting
(contd..)
➔ Communication: Flow charts are better way of
communicating the logic of a system to all
concerned.
➔ Effective analysis: With the help of flowchart,
problem can be analyzed in more effective way.
➔ Proper documentation: Program flowcharts serve
as a good program documentation, which is needed
for various purposes.
➔ Efficient Coding: The flowcharts act as a guide or
blueprint during the systems analysis and program
development phase.
Advantages of Using Flowcharts
45
➔ Proper Debugging: The flowchart helps in
debugging process.
➔ Efficient Program Maintenance: The maintenance
of operating program becomes easy with the help of
flowchart. It helps the programmer to put efforts
more efficiently on that part.
46
Advantages of Using Flowcharts (contd)
Flow chart
47
Example: Draw a flowchart to sum two numbers.
Algorithm
Step 1 : Start
Step 2 : Read value for a side A
Step 3 : [Compute] Area A * A
Step 4 : Print Area
Step 5 : Stop
Problem: Algorithm and a flow chart to calculate
area of square.
48
Flow Chart
49
Algorithm
Step1 : Start
Step 2 : Enter Three Numbers A, B and C
Step 3 : Compute Average = (A+B+C)/3
Step 4 : Print Average
Step 5 : Stop
Problem: Algorithm and flowchart to find the average
of three numbers.
50
,C
Flow Chart
51
52
Relationship between Celsius and Fahrenheit
53
Algorithm:
Step 1: Start
Step 2: Read Temperature in Fahrenheit F
Step 3: C (F - 32)*(5/9)
Step 4: Print Temperature in Celsius C
Step5: End
54
Problem 3: Convert temperature Fahrenheit to
Celsius
55
Flow Chart
Algorithm:
Step 1: Start
Step 2: Read Temperature in Celsius C
Step 3: F ( 9 * C / 5 ) + 32
Step 4: Print Temperature in Fahrenheit F
Step5: End
56
Problem 3: Convert temperature Celsius to
Fahrenheit
57
1. Write an Algorithm and Draw a Flowchart to find
the third angle of a triangle if two angles are given.
2. Write an Algorithm and Draw a Flowchart to
enter Principal, Time, Rate and calculate the
simple interest
3. Write an Algorithm and Draw a Flowchart to
calculate a bike’s mileage from the given total
distance (integer value) traveled (in km) and spent
fuel (in liters, float number up to 2 decimal point).
58
Flow Chart
59
Write an algorithm to find out if a given number is Even
or Odd.
Step 1: Start
Step 2: Declare variable a
Step 3: Input a
Step 4: if a%2==0
go to step 5
else go to step 6
Step 5: Print Even
Step 6: Print Odd
Step 7: Stop
Algorithm
Step 1: Start
Step 2: Declare variables A, B
Step 3: Enter two numbers A and B
Step 4: If A>B
Go to Step 6
else go to Step 5
Step 5: If B>A
Go to step 7
else go to step 8
Step 6: Print A is greater
Step 7: Print B is greater
Step 8: Print A and B are Equal
Step 9: Stop
Problem: Write the algorithm and draw the
flowchart to compare two numbers?
60
Flow Chart
61
62
Step 1: Start
Step 2: Declare variables M1, M2, M3, M4, GRADE
Step 3: Input M1,M2,M3,M4
Step 4: GRADE ← (M1+M2+M3+M4)/4
Step 5: if (GRADE >=60)
then go to step 7
else go to step 6
Step 6: Print “FAIL”
Step 7: Print “PASS”
Step 8: Stop
Write an algorithm to determine a student’s final grade
and indicate whether it is pass or fail. The final grade is
calculated as the average of four marks.
Flow Chart
START
Input
M1,M2,M3,M4
GRADE←(M1+M2+M3+M4)/4
IS
GRADE>=60
STOP
YES
NO
63
Print Fail Print Pass
Algorithm
Step 1: Start
Step 2: Declare sum, I, N
Step 2: Read number N
Step 3: Set sum = 0 and i = 1
Step 4: Repeat steps 5 and 6 until i<=N
Step 5: update sum as sum sum + i
Step 6: increment i
Step 7: Print sum
Step 8: Stop
Algorithm and a flow chart to calculate the
sum of N natural numbers.
64
65
Practice session:
Draw the flowchart to print sum of all even numbers
between 1 to n.
66
Ad

More Related Content

What's hot (20)

CLASSIFICATION OF COMPUTER
CLASSIFICATION OF COMPUTERCLASSIFICATION OF COMPUTER
CLASSIFICATION OF COMPUTER
GLOBAL TECHNOLOGY CONSULTANCY
 
Generations Of Programming Languages
Generations Of Programming LanguagesGenerations Of Programming Languages
Generations Of Programming Languages
py7rjs
 
Introduction to Programming Languages
Introduction to Programming LanguagesIntroduction to Programming Languages
Introduction to Programming Languages
educationfront
 
introduction computer programming languages
introduction computer programming languages introduction computer programming languages
introduction computer programming languages
BakhatAli3
 
Software and It's types
Software and It's typesSoftware and It's types
Software and It's types
Uttar Tamang ✔
 
1st assignment introduction to computer
1st assignment  introduction to computer1st assignment  introduction to computer
1st assignment introduction to computer
Nadeem Hussain Bajkani
 
Basic+machine+organization
Basic+machine+organizationBasic+machine+organization
Basic+machine+organization
Bilal Maqbool ツ
 
Classification of computers
Classification of computersClassification of computers
Classification of computers
Dominic Boye Jnr.
 
Introduction to programming languages
Introduction to programming languagesIntroduction to programming languages
Introduction to programming languages
Sayed Mahmoud AbdEl Rahman
 
computer languages
computer languagescomputer languages
computer languages
Rajendran
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
Syed Zaid Irshad
 
Basic operation of computer
Basic operation of computerBasic operation of computer
Basic operation of computer
युनीक तुषार गुप्ता
 
Computer Language
Computer LanguageComputer Language
Computer Language
Deepak Yadav
 
COMPUTER SYSTEM AND ITS COMPONENTS
COMPUTER SYSTEM AND ITS COMPONENTSCOMPUTER SYSTEM AND ITS COMPONENTS
COMPUTER SYSTEM AND ITS COMPONENTS
SHIVALI NEGI
 
Introduction to qbasic
Introduction to qbasicIntroduction to qbasic
Introduction to qbasic
Richa Karthikeyan
 
Computer Software
Computer SoftwareComputer Software
Computer Software
julinaincgumanit
 
Computer fundamental
Computer fundamentalComputer fundamental
Computer fundamental
Gas & Oil Pakistan Ltd.
 
Computer literacy
Computer literacyComputer literacy
Computer literacy
Reynalyn Navales
 
Programming Fundamental Slide No.1
Programming Fundamental Slide No.1Programming Fundamental Slide No.1
Programming Fundamental Slide No.1
Arslan Hussain
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek
 

Similar to L1. Basic Programming Concepts.pdf (20)

asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...
vaishalisharma125399
 
Programming _Language of Logic_ PPT.pptx
Programming _Language of Logic_ PPT.pptxProgramming _Language of Logic_ PPT.pptx
Programming _Language of Logic_ PPT.pptx
MsKGowriDhilipkumar
 
Programming str_Language of Logic/c.pptx
Programming str_Language of Logic/c.pptxProgramming str_Language of Logic/c.pptx
Programming str_Language of Logic/c.pptx
MsKGowriDhilipkumar
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie
 
introduction to problem solving and programming
introduction to problem solving and programmingintroduction to problem solving and programming
introduction to problem solving and programming
chaudhariresham6
 
01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx
JustineLincopinesAlm
 
Power Point Introduction To Programming 1
Power Point Introduction To Programming 1Power Point Introduction To Programming 1
Power Point Introduction To Programming 1
FabianDaffa3
 
Module 1 python.pptx
Module 1 python.pptxModule 1 python.pptx
Module 1 python.pptx
AnuragJoshi813963
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
NenavathSurendhar
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
TeddyDaka
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2
ITNet
 
Cp 111 lecture 2
Cp 111 lecture 2Cp 111 lecture 2
Cp 111 lecture 2
HafidhyMasoud
 
Programming C ppt for learning foundations
Programming C ppt for learning foundationsProgramming C ppt for learning foundations
Programming C ppt for learning foundations
ssuser65733f
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
ssusera8c91a
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
praveena p
 
C progrmming
C progrmmingC progrmming
C progrmming
Shivam Singhal
 
6272 cnote
6272 cnote6272 cnote
6272 cnote
P Kiran Sree
 
10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz
Shahbaz Ahmad
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
Department of Education - Philippines
 
asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...asic computer is an electronic device that can receive, store, process, and o...
asic computer is an electronic device that can receive, store, process, and o...
vaishalisharma125399
 
Programming _Language of Logic_ PPT.pptx
Programming _Language of Logic_ PPT.pptxProgramming _Language of Logic_ PPT.pptx
Programming _Language of Logic_ PPT.pptx
MsKGowriDhilipkumar
 
Programming str_Language of Logic/c.pptx
Programming str_Language of Logic/c.pptxProgramming str_Language of Logic/c.pptx
Programming str_Language of Logic/c.pptx
MsKGowriDhilipkumar
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie
 
introduction to problem solving and programming
introduction to problem solving and programmingintroduction to problem solving and programming
introduction to problem solving and programming
chaudhariresham6
 
Power Point Introduction To Programming 1
Power Point Introduction To Programming 1Power Point Introduction To Programming 1
Power Point Introduction To Programming 1
FabianDaffa3
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
TeddyDaka
 
Computer programing 111 lecture 2
Computer programing 111 lecture 2Computer programing 111 lecture 2
Computer programing 111 lecture 2
ITNet
 
Programming C ppt for learning foundations
Programming C ppt for learning foundationsProgramming C ppt for learning foundations
Programming C ppt for learning foundations
ssuser65733f
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
praveena p
 
10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz
Shahbaz Ahmad
 
Ad

More from MMRF2 (12)

Environmental Awareness for environment pptx
Environmental Awareness for environment pptxEnvironmental Awareness for environment pptx
Environmental Awareness for environment pptx
MMRF2
 
Hrm 402 Presentation unionism and collective bargaining pptx
Hrm 402 Presentation unionism and collective bargaining pptxHrm 402 Presentation unionism and collective bargaining pptx
Hrm 402 Presentation unionism and collective bargaining pptx
MMRF2
 
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.pptXRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
MMRF2
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
Presentation dlide Bus 201.pptx
Presentation dlide Bus 201.pptxPresentation dlide Bus 201.pptx
Presentation dlide Bus 201.pptx
MMRF2
 
PDF document 7.pdf
PDF document 7.pdfPDF document 7.pdf
PDF document 7.pdf
MMRF2
 
PDF document 6.pdf
PDF document 6.pdfPDF document 6.pdf
PDF document 6.pdf
MMRF2
 
PDF document 5.pdf
PDF document 5.pdfPDF document 5.pdf
PDF document 5.pdf
MMRF2
 
PDF document 4.pdf
PDF document 4.pdfPDF document 4.pdf
PDF document 4.pdf
MMRF2
 
PDF document 3.pdf
PDF document 3.pdfPDF document 3.pdf
PDF document 3.pdf
MMRF2
 
PDF document 2.pdf
PDF document 2.pdfPDF document 2.pdf
PDF document 2.pdf
MMRF2
 
PDF document.pdf
PDF document.pdfPDF document.pdf
PDF document.pdf
MMRF2
 
Environmental Awareness for environment pptx
Environmental Awareness for environment pptxEnvironmental Awareness for environment pptx
Environmental Awareness for environment pptx
MMRF2
 
Hrm 402 Presentation unionism and collective bargaining pptx
Hrm 402 Presentation unionism and collective bargaining pptxHrm 402 Presentation unionism and collective bargaining pptx
Hrm 402 Presentation unionism and collective bargaining pptx
MMRF2
 
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.pptXRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
XRobbins_EOB10_Basic_PPT_CH04 entrepreneurship.ppt
MMRF2
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
Presentation dlide Bus 201.pptx
Presentation dlide Bus 201.pptxPresentation dlide Bus 201.pptx
Presentation dlide Bus 201.pptx
MMRF2
 
PDF document 7.pdf
PDF document 7.pdfPDF document 7.pdf
PDF document 7.pdf
MMRF2
 
PDF document 6.pdf
PDF document 6.pdfPDF document 6.pdf
PDF document 6.pdf
MMRF2
 
PDF document 5.pdf
PDF document 5.pdfPDF document 5.pdf
PDF document 5.pdf
MMRF2
 
PDF document 4.pdf
PDF document 4.pdfPDF document 4.pdf
PDF document 4.pdf
MMRF2
 
PDF document 3.pdf
PDF document 3.pdfPDF document 3.pdf
PDF document 3.pdf
MMRF2
 
PDF document 2.pdf
PDF document 2.pdfPDF document 2.pdf
PDF document 2.pdf
MMRF2
 
PDF document.pdf
PDF document.pdfPDF document.pdf
PDF document.pdf
MMRF2
 
Ad

Recently uploaded (20)

Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 

L1. Basic Programming Concepts.pdf

  • 2. Introduction ▪ Computer programs are the collections of instructions that tell a computer what to do, how to interact with the user, interact with the computer hardware and process data. ▪ The first programmable computers required the programmers to write explicit (clear & exact) instructions to directly manipulate the hardware of the computer. 2
  • 3. Computer Programs ❖Computer programs, known as software. You tell a computer what to do through programs. ❖Without programs, a computer is an empty machine. ❖Computers do not understand human languages, so you need to use computer languages to communicate with them. 3
  • 4. Programming Languages ⚫ Programs are written using programming languages. ⚫ Programming language is an agreed upon format of symbols that allow a programmer to instruct a computer to perform certain predefined tasks. 4
  • 5. Types of programming languages Some types of programming languages are: ⚫ Machine languages ⚫ Assembly languages ⚫ High-level languages 5
  • 6. Machine language ⚫ Low-Level language is the only language which can be understood by the computer. ⚫ Low-level language is also known as Machine Language. ⚫ Sometimes called machine code or object code ⚫ The machine language contains only two symbols 1 & 0. All the instructions of machine language are written in the form of binary numbers 1's & 0's. ⚫ A computer can directly understand the machine language. 6
  • 7. Assembly language ⚫ Middle-level language in which the instructions are created using symbols such as letters, digits and special characters. ⚫ In assembly language, we use predefined words called mnemonics. Binary code instructions in low-level language are replaced with mnemonics and operands in middle-level language. ⚫ But the computer cannot understand mnemonics, so we use a translator called Assembler to translate mnemonics into machine language. 7
  • 8. Assembly language (cont.) ⚫ Assembler is a translator which takes assembly code as input and produces machine code as output. ⚫ That means, the computer cannot understand middle-level language, so it needs to be translated into a low-level language to make it understandable by the computer. ⚫ Assembler is used to translate middle-level language into low-level language. 8
  • 9. High-level languages ⮚High-level language is a computer language which can be understood by the users. ⮚ The high-level language is very similar to human languages and has a set of grammar rules that are used to make instructions more easily. ⮚Every high-level language has a set of predefined words known as Keywords and a set of rules known as Syntax to create instructions. 9
  • 10. High-level languages (Contd..) ⮚The high-level language is easier to understand for the users but the computer can not understand it. ⮚ High-level language needs to be converted into the low-level language to make it understandable by the computer. ⮚We use Compiler or interpreter to convert high-level language to low-level language. 10
  • 11. Examples of High-Level Languages Java (An object oriented language). General purpose – gaining popularity rapidly. COBOL (Common Business Oriented Language). Developed for business applications. FORTRAN (FORmula TRANslation). Developed for Engineering & Scientific Applications. BASIC (Beginner All-purpose Symbolic Instructional Code). 11
  • 12. Examples of High-Level Languages (cont.) ⚫ C is designed to support only procedure-oriented programming. Popular language for developing system applications such as operating system and compilers. ⚫ C++ is extension of C programming language that supports object-oriented programming and procedure oriented approach. General purpose and most popular. ⚫ Visual Basic – Basic-like visual language developed by Microsoft. 12
  • 13. Examples of High-Level Languages (cont.) ⚫ PROLOG - is a language for PROgramming in LOGic. Artificial Intelligence. ⚫ Ada (named after Ada Lovelace) ⚫ Python - is a general purpose programming language that's used to do things from testing microchips at Intel, to building video games. 13
  • 14. The Programming Process Programming involves five steps to develop a program. 1. Defining the problem: State the problem clearly. 2. Describe the input and output information. 3. Work the problem by hand (or with a calculator) for a specific set of data. 4. Develop a solution that is general in nature. 5. Testing the program: Test the solution with a variety of data sets. 14
  • 15. Why Programming? ⚫ There are some good reasons for learning programming: ⚫ Computer programming can be used to create innovative and functional software. Computer programmers can use their creativity to design software that will be useful to people, or that will improve the way that people work. ⚫ Computers can also be programmed to perform specific tasks using mathematical algorithms and logic. ⚫ It can also be used to create websites, games, and other digital content. 15
  • 16. Different Phases of Programming Task A typical programming task can be divided into three phases: 1) Pre-programming phase (or Problem Solving Phase) • Produce an ordered sequence of steps that describe solution of problem. • Algorithms as well as Flowcharts are implemented in problem solving phase of programming. 2) Programming phase(or Implementation Phase) ⚫ implement the program in some programming language 3) Maintenance Phase ⚫ Maintain/modify to meet changed requirements or to correct errors. 16
  • 17. This phase requires four steps: ⮚Analyzing the problem. ⮚Developing the Input-Process-Output (IPO) Chart. ⮚Writing the algorithm. ⮚Drawing the flowchart. Pre-Programming Phase 17
  • 18. Analyzing the problem ❖Understand and analyze the requirements of the problem. ❖Identify the following: ⚫ Data requirement. ⚫ Processing requirement or procedures that will be needed to solve the problem. ⚫ The output. 18
  • 19. All these requirements can be presented in a Problem Analysis Chart (PAC) as follows: Data Processing Output Given in the problem or provided by the user List of processing required or procedures Output/ desired result 19
  • 20. Problem 1: Calculate the salary of an employee who works by hourly basis. The formula to be used is: Salary = Hour works * Pay rate Data Processing Output Hours work, Pay rate Salary = Hours works * pay rate Salary 20
  • 21. Problem 2: Draw a Problem Analysis Chart (PAC) to find the area of circle where area = pi * radius * radius Data Processing Output radius area = 3.14 x radius x radius area 21
  • 22. Problem 3. Draw a problem analysis chart to convert the distance in miles to kilometers where 1.609 per mile. Data Processing Output Distance in miles Kilometers = 1.609 x miles Distance in kilometers 22
  • 23. Problem 4. Draw a problem analysis chart to find the area of a triangle. Problem 5: Draw a problem analysis chart to evaluate the following expression. EXP= a²+2ab+b² 23
  • 24. • Extends and organizes the information in the PAC. • It shows in more details what items are input, what to be processed and what will be the result or output. Developing the Input-Process-Output (IPO) Chart 24
  • 25. Problem 1. Develop an IPO chart to convert the distance in miles to kilometers where 1.609 kilometers per mile. Input Processing Output Distance in miles -Enter distance -Kilometers = 1.609 x miles -Display kilometers -Distance in kilometers 25
  • 26. 26 Constant and Variable Constant: A constant can be defined as a fixed value, which is used in algebraic expressions and equations. A constant does not change over time and has a fixed value. For example, the size of a shoe or cloth or any apparel will not change at any point. Variables: Variables are terms which can change or vary over time. Its value does not remain constant, unlike constants. For example, the height and weight of a person do not always remain constant, and hence they are variables.
  • 27. ❖In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. ❖It takes a set of input(s) and produces the desired output. ❖Before writing a program, a programmer must start with an algorithm of the program following with flowchart and pseudo code. ❖Purpose: Algorithms provide a better understanding towards programming and helps in building better problem-solving logic. Algorithms help the programmer to write code faster by following steps in Algorithm. What is algorithm? 27
  • 28. ❖It is not the entire program or code; it is simple logic to a problem represented as an informal description in the form of a flowchart or pseudo code. What is algorithm? (contd..) 28
  • 29. ❖Problem: A problem can be defined as a real-world problem for which you need to develop a program or set of instructions. An algorithm is a set of instructions. ❖Algorithm: An algorithm is defined as a step-by-step process that will be designed for a problem. ❖Input: After designing an algorithm, the algorithm is given the necessary and desired inputs. ❖Processing unit: The input will be passed to the processing unit, producing the desired output. ❖Output: The outcome or result of the program is referred to as the output. What is algorithm? (Contd..) 29
  • 30. Examples of Algorithm Problem 1. Write an algorithm to “Make Tea” Algorithm Step1. Start. Step2. Take water in pan Step3. Boil the water Step4. Add sugar and Tea leaves Step5. Add milk Step6. Boil it Step7. Pour it into cup Step8. Stop 30
  • 31. There may be more than one way to solve a problem, so there may be more than one algorithm for a problem. Before writing an algorithm for a problem, one should find out what is/are the inputs to the algorithm and what is/are expected output after running the algorithm. 31
  • 32. While writing algorithms we will use following symbols for different operations: + for Addition - for Subtraction * for Multiplication / for Division and for assignment. For example A X*3 means A will have a value of X*3. 32
  • 33. ⮚ Input: An algorithm requires some input values. An algorithm can be given a value other than 0 as input. ⮚ Output: At the end of an algorithm, you will have one or more outcomes. ⮚ Unambiguity: A perfect algorithm is defined as unambiguous, which means that its instructions should be clear and straightforward. ⮚ Finiteness: An algorithm must be finite. Finiteness in this context means that the algorithm should have a limited number of instructions, i.e., the instructions should be countable. ⮚ Effectiveness: Because each instruction in an algorithm affects the overall process, it should be acceptable. ⮚ Language independence: An algorithm must be language-independent, which means that its instructions can be implemented in any language and produce the same results. The essential properties of Algorithm are: 33
  • 34. Steps for Developing an Algorithm ✔Define the problem: State the problem you are trying to solve in clear and concise terms. ✔List the inputs (information needed to solve the problem) and the outputs (what the algorithm will produce as a result) ✔Describe the steps needed to convert or manipulate the inputs to produce the outputs. keep refining the steps until they are effectively computable operations. ✔Test the algorithm: choose data sets and verify that your algorithm works! 34
  • 35. Examples of Algorithm Problem 2: Find the area of a Circle of radius r. Algorithm: Step1: Start Step2: Readinput the Radius r of the Circle Step3: Area PI*r*r // calculation of area Step4: Print Area Step5: Stop 35
  • 36. Problem 3: Write an algorithm and draw a flow chart to read two numbers and find their sum. Algorithm: Step 1 : Start Step 2 : Input first number A Step 3 : Input second number B Step 4 : Total = A+B Step 5 : Print Total Step 6 : Stop 36
  • 37. Practice Algorithm ✔Algorithm 1: Find the largest number between two numbers ✔Algorithm 2: Find the odd and even number from a given input value. 37
  • 38. Flowchart ◆ A flowchart is simply a graphical representation of steps. It shows steps in sequential order and is widely used in presenting the flow of algorithms, workflow or processes. ◆ Typically, a flowchart shows the steps as boxes of various kinds, and their order by connecting them with arrows. ◆ Flowcharts are very helpful in writing programs and explaining them to others. ◆ Flowcharts are quite helpful in understanding the logic of complicated and lengthy problems. ◆ Once the flowchart is drawn, it becomes easy to write the program in any programming language. 38
  • 39. When to use a flowchart? ★ It is most importantly used when the programmers make projects. As a flowchart is a basic step to make the design of projects. ★ When the flowcharts of a process are drawn, the programmer understands the non-useful parts of the process. So flowcharts are used to separate useful logic from the unwanted parts. ★ Since the rules and procedure of drawing a flowchart are universal, flowchart serves as a communication channel to the people who are working on the same project for better understanding. 39
  • 40. BASIC FLOWCHART SYMBOLS ARE GIVEN IN THE NEXT SLIDE 40
  • 41. Symbol Name Use in flowcharts Start/Stop (Oval) Denotes the beginning or end of the program Flow line Show the direction of data flow or logical solution Process (Rectangle) Indicates a process to be carried out such as addition, subtraction, multiplication and division. Input/Output (Parallelogram) Indicates input to the program or output from the program 41
  • 42. Symbol Name Use in flowcharts Question, Decision (Diamond) Used for making a decision. The program should continue along one of two routes; either true or false based on certain conditions. Connector (Circle) Connection of flowchart on the same page. Connector Connection of flowchart from one page to another. 42
  • 43. 1. Use conventional flowchart symbols. Each symbol should have one exit point except the decision symbol. As far as possible each symbol should also have one entry point and in the case of decision symbol, it is a must. 2. The flow of control in the problem can be shown with the help of arrows. But, the flow lines should not cross each other. 3. The processing logic within the flowchart should flow from top to bottom and from left to right. 4. The instructions written within the various flowchart symbols should be independent of programming languages. General Rules for flowcharting 43
  • 44. 5. The flow lines coming out of the decision symbol should be properly labelled. 6. If the flowchart becomes large and complex (on same page) then make use of ordinary connector symbols to avoid crossing of flow lines. 7. Every flow chart must have the start and End points. 44 General Rules for flowcharting (contd..)
  • 45. ➔ Communication: Flow charts are better way of communicating the logic of a system to all concerned. ➔ Effective analysis: With the help of flowchart, problem can be analyzed in more effective way. ➔ Proper documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes. ➔ Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase. Advantages of Using Flowcharts 45
  • 46. ➔ Proper Debugging: The flowchart helps in debugging process. ➔ Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part. 46 Advantages of Using Flowcharts (contd)
  • 47. Flow chart 47 Example: Draw a flowchart to sum two numbers.
  • 48. Algorithm Step 1 : Start Step 2 : Read value for a side A Step 3 : [Compute] Area A * A Step 4 : Print Area Step 5 : Stop Problem: Algorithm and a flow chart to calculate area of square. 48
  • 50. Algorithm Step1 : Start Step 2 : Enter Three Numbers A, B and C Step 3 : Compute Average = (A+B+C)/3 Step 4 : Print Average Step 5 : Stop Problem: Algorithm and flowchart to find the average of three numbers. 50
  • 53. 53
  • 54. Algorithm: Step 1: Start Step 2: Read Temperature in Fahrenheit F Step 3: C (F - 32)*(5/9) Step 4: Print Temperature in Celsius C Step5: End 54 Problem 3: Convert temperature Fahrenheit to Celsius
  • 56. Algorithm: Step 1: Start Step 2: Read Temperature in Celsius C Step 3: F ( 9 * C / 5 ) + 32 Step 4: Print Temperature in Fahrenheit F Step5: End 56 Problem 3: Convert temperature Celsius to Fahrenheit
  • 57. 57 1. Write an Algorithm and Draw a Flowchart to find the third angle of a triangle if two angles are given. 2. Write an Algorithm and Draw a Flowchart to enter Principal, Time, Rate and calculate the simple interest 3. Write an Algorithm and Draw a Flowchart to calculate a bike’s mileage from the given total distance (integer value) traveled (in km) and spent fuel (in liters, float number up to 2 decimal point).
  • 59. 59 Write an algorithm to find out if a given number is Even or Odd. Step 1: Start Step 2: Declare variable a Step 3: Input a Step 4: if a%2==0 go to step 5 else go to step 6 Step 5: Print Even Step 6: Print Odd Step 7: Stop
  • 60. Algorithm Step 1: Start Step 2: Declare variables A, B Step 3: Enter two numbers A and B Step 4: If A>B Go to Step 6 else go to Step 5 Step 5: If B>A Go to step 7 else go to step 8 Step 6: Print A is greater Step 7: Print B is greater Step 8: Print A and B are Equal Step 9: Stop Problem: Write the algorithm and draw the flowchart to compare two numbers? 60
  • 62. 62 Step 1: Start Step 2: Declare variables M1, M2, M3, M4, GRADE Step 3: Input M1,M2,M3,M4 Step 4: GRADE ← (M1+M2+M3+M4)/4 Step 5: if (GRADE >=60) then go to step 7 else go to step 6 Step 6: Print “FAIL” Step 7: Print “PASS” Step 8: Stop Write an algorithm to determine a student’s final grade and indicate whether it is pass or fail. The final grade is calculated as the average of four marks.
  • 64. Algorithm Step 1: Start Step 2: Declare sum, I, N Step 2: Read number N Step 3: Set sum = 0 and i = 1 Step 4: Repeat steps 5 and 6 until i<=N Step 5: update sum as sum sum + i Step 6: increment i Step 7: Print sum Step 8: Stop Algorithm and a flow chart to calculate the sum of N natural numbers. 64
  • 65. 65
  • 66. Practice session: Draw the flowchart to print sum of all even numbers between 1 to n. 66
  翻译: