0% found this document useful (0 votes)
10 views11 pages

CP Lab 2

The document contains 8 problem statements involving writing computer programs to perform various calculations and generate numeric series. For each problem statement, it provides the input, output, flow chart and algorithm to write the program.

Uploaded by

Kamran Ahmed
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)
10 views11 pages

CP Lab 2

The document contains 8 problem statements involving writing computer programs to perform various calculations and generate numeric series. For each problem statement, it provides the input, output, flow chart and algorithm to write the program.

Uploaded by

Kamran Ahmed
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/ 11

Page 1

Roll No. _19CS78_ Date of Conduct: _______________________


Submission Date: _________________________ Grade Obtained: ________________________
LAB DATA ANALYSIS ABILITY TO
SUBJECT CALCULATION OBSERVATION/R
PERFORMANCE AND CONDUCT PRESENTATION SCORE
KNOWLEDGE AND CODING ESULTS
INDICATOR INTERPRETATION EXPERIMENT

EXERCISE 2
For each of the following problem statement, create the IPO chart with
algorithm and flow chart.

Problem Statement 1
There are two circular grounds Ground-A and Ground-B. Ground-A is having
diameter of 15 meters and Ground-B is having diameter of 20 meters. Mohsin is
running in Ground-A and Neetesh is running in Ground-B. Write a computer
program that asks the user to input the time taken, in seconds, to complete one
compete round of the ground by both the friends and displays who is running
faster.

 Time1  Processing items  Mohsin is running


 Time2  speed_m=pi*diameter_1/ti fast.
me1  Neetesh is running
 speed_n=pi*diameter_2/tim fast.
e2
 Algorithm
Step 01: start
Step 02: set pi=3.142;
Step 03: input time1 and time2
from user
Step 04: calculate
speed_m=pi*diameter_1/time1
Step 05: calculate
speed_n=pi*diameter_2/time2
Step 06: check condition
(speed_m>speed_n) if true then
step 06 otherwise step 07
Step 07: print Mohsin is running
fast.
Step 08: print Neetesh is
running fast.
Step 09: End
Page 2
Page 3

Problem Statement 2
Write a computer program that displays the sum of first 10 odd multiples of 3.

 Processing items  Sum of first 10 odd


 sum+=i*3; multiples of 3
 i=i+1
 Algorithm
Step 01: start
Step 02: set sum=0
and i=1
Step 03: repeat step
04 and step 05 while
i<21
Step 04: if i MODD =0
then skip step 05
Step 05: calculate
sum+=i*3;
Step 06: print Sum of
first 10 odd multiples
of 3
Step 07: End
Page 4

Problem Statement 3
Write a computer program that generates and displays the first N three digit odd
numbers. Whereas the number N is provided by the user.

 Number  Processing items  Series of odd


sum=sum+2; numbers of three
 Algorithm digits
Step 01: start
Step 02:input number
from user
Step 03: set i=1
Step 04: repeat step
05 and 06 while
i<=number
Step 05: print odd
number
Step 06: number
increase by 2
Step 07: set i=i+1
Step 07: End
Page 5

Problem Statement 4
Write a computer program that displays the sum of last 5 four digit multiples of
5.

 Processing items  sum of last 5 four


sum=sum+temp; digit multiples of 5
temp=temp-5;
 Algorithm
Step 01: start
Step 02:set
sum=0,temp=9995 and
i=0
Step 03: repeat step
05 while i<5
Step 04: calculate
sum=sum+temp;
temp=temp-5;
Step 05: sum of last
four digit multiples of 5
Step 06: End
Page 6

Problem Statement 5
Write a computer program that asks the user to input the starting number and
ending number of the range. The program should display the number of
multiples of 5 in between that range.

 Starting number  Processing  The number of


 Ending number items multiples of 5 in
start=sum+5 between starting
start%5==0 number and ending
 Algorithm number
Step 01: start
Step 02: input starting
and ending number from
user
Step 03: set
start=start+5
Step 04: repeat step 05
to 08 while start<end
Step 05: if(start%5==0)
then GOTO step 06
otherwise step 07
Step 06: print start
Step 07: continue
Step 08: start+1
Step 09: End
Page 7

Problem Statement 6
Write a computer program that generates and displays the following series of
numbers:
15, 30, 45, 60, 75, 90, 105, 120, 135, 150

Processing items  15,30,45,60,75,90,


i%15==0 105,120,135,150
 Algorithm
Step 01: start
Step 02: set i=0 and
end= 165
Step 03: repeat step
05 to 08 while i<end
Step 04:
if(start %15==0) then
GOTO step 06
otherwise step 07
Step 05: print i
Step 06: continue
Step 07: i+1
Step 08: End
Page 8

Problem Statement 7
Write a computer program that generates and displays the following series of
numbers:
1, 4, 9, 16, 25, 36, 49, 64, 81, 100

 Processing items  1,4,9,16,25,36,49,


 Algorithm 64, 81,100
Step 01: start
Step 02: set i=1
Step 03: repeat step
04 and 05 while i<11
Step 04: print square
of i
Step 05: i+1
Step 06: End
Page 9
Page 10

Problem Statement 8
Write a computer program that generates and displays the following series of
numbers:
90, 72, 56, 42, 30, 20, 12, 6, 2, 0

 Processing items  90,72,56,42,30,20,


temp1=temp1-2; 12,6,2,0
temp=temp-temp1;
 Algorithm
Step 01: start
Step 02: set
temp=110,temp1=22
and i=0
Step 03: repeat step
04 to 07 while i<10
Step 04: calculate
temp1-=2;
temp-=temp1;
Step 05: print temp
Step 07: i+1
Step 08: End
Page 11

You might also like