[go: up one dir, main page]

0% found this document useful (0 votes)
13 views12 pages

PCI Unit 1.1 Algorithms 1

Uploaded by

Mayur Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views12 pages

PCI Unit 1.1 Algorithms 1

Uploaded by

Mayur Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Course: Programming in C

Unit-1: Program Logic Development

Faculty:
Mr. A. A. Patel Khan
Dept. of Computer Technology
K. K. Wagh Polytechnic, Nashik
Unit-I Program Logic Development
Topic: Algorithms

Unit-I Program Logic Development


Contents

• Steps for solving problem


1
• Algorithm
2
• Flowchart
3
• Questions
4

Unit-I Program Logic Development


Steps for Solving Problem
Problem Solution

1 . Assignments
1 • Input
2. Calculations
2 • Processing 3. Decision Making

3 • Output 4. Repetitions/Loop

Unit-I Program Logic Development


Algorithm
Definition: An algorithm is a logical sequence of well-defined instructions
to solve a problem.
It is a sequence of logical steps to solve the give problem

•Each instruction for one operation (pseudo instruction / code)


•Each instruction is one step
•First step instruction is ‘Start’
•Last step instruction is ‘Stop’ or ‘End’
•Middle steps may be input, processing & output operations

Unit-I Program Logic Development


Example of Algorithm
Algorithm to find the sum of two numbers
Algorithm:
Step-1: Start
Step-2: Declare variables no1 & no2
Step-3: Accept two numbers as no1 & no2
Step-4: Find sum = no1 + no2
Step-5: Display sum
Step-6:Stop

Unit-I Program Logic Development


Keywords/Pseudo instructions for Algorithm

•Declaration: Declare , Define


•Input operations: Accept , Input, Read
•Output operations: Print, Display , Write
•Assignment operation: Let, Assign
•Calculation operations: Find, Calculate
•Decision Making: if-else, do step-n
•Branching operation: goto step-n
•Looping operations: While , do, repeat, until

Unit-I Program Logic Development


Sample Algorithm (Input-Output)
1.Write an Algorithm to find the area and perimeter of Rectangle

Algorithm:
Step-1: Start
Step-2: Accept length & breadth of rectangle
Step-3: Find Area= length * breadth
Step-4: Print Area
Step-5: Find perimeter = 2 * (length + breadth)
Step-6: Display perimeter
Step-7:Stop
Unit-I Program Logic Development
Assignment on Algorithm (Input-Output)
1. Write an Algorithm to find area and circumference of a circle
Area = Pi *r * r, circumference = 2*pi*r
2. Write an Algorithm to calculate simple interest for the
principle amount deposited in a bank for n-No. of years
with specified rate of interest
SI = (P * N * R ) / 100
P- Principle amount
N- No. of years
R- Rate of interest
SI- Simple Interest

Unit-I Program Logic Development


Sample Algorithm (Decision Making)
2. Write an Algorithm to find greater number from two numbers

Algorithm:
Step-1: Start
Step-2: Read no1 & no2 as two numbers
Step-3: If (no1 > no2)
-then Print no1 as greater
-else Print no2 as greater
Step-4: Stop

Unit-I Program Logic Development


Assignment on Algorithm (Decision Making)

1. Write an Algorithm to accept marks of 5 subjects


and find the Result as Distinction, first class, second
class and pass

Unit-I Program Logic Development


Thank you
Have
a
Nice Day

Unit-I Program Logic Development

You might also like