0% found this document useful (0 votes)
7 views

CP Lab 1

The document contains 5 problem statements related to computer programming. For each problem statement, it provides the input, output, algorithm and flowchart. The problems include calculating area of a triangle, distance traveled in a circular ground, swapping values of two variables, finding average of digits in a number, and displaying minimum notes for a given amount.

Uploaded by

Kamran Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CP Lab 1

The document contains 5 problem statements related to computer programming. For each problem statement, it provides the input, output, algorithm and flowchart. The problems include calculating area of a triangle, distance traveled in a circular ground, swapping values of two variables, finding average of digits in a number, and displaying minimum notes for a given amount.

Uploaded by

Kamran Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

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

1. For each of the following statement write down the flow chart symbol you will use.

A B C D E F

Statement Flow chart symbol

Terminate the process A

Set the variable a = 5 B

Calculate the square of a number B

Getting name of the user D

Initiate the process A

Continue a flow chart on the next page F

Displaying the marks of student D

Executing another process C

Prompting the user D

Continue a flow chart on the same page E

2. Write down the problem statement for the following flow chart.

19CS78
2

3. For each of the following problem statement, create the IPO chart with
algorithm and Flow chart.

Problem Statement 1
Write a computer program that accepts the base and height of a right angle triangle
from the user and displays the area of the triangle.

 Base of triangle  Processing items  Area of triangle


 Height of triangle area=base*height/2
 Algorithm
Step 01: start
Step 02: input base and
height of triangle from the
user.
Step 03: calculate area =
base*height/2
Step 04: print area of
triangle
Step 05: End

19CS78
3

Problem Statement 2
A person is running in a circular ground. Write a computer program that asks the
user to input the radius of the ground in meters and the number of rounds the
person completes. The program should display the amount of distance travelled by
the person in meters.

19CS78
4

 Radius of ground  Processing items  Distance traveled by


 Round of ground dis_trav=2*pi*radius*rou person in meters.
nd
 Algorithm
Step 01: start
Step 02: input radius and
round from users
Step 03: calculate distance
traveled as
dis_trav=2*pi*radius*
round
Step 04: print distance
traveled by person
(dis_trav)
Step 05: End

Problem Statement 3
Write a program that asks the user to enter two integer numbers, stores them in
variables num1 and num2 respectively. The program swaps the values of two
variables with each other without using a third variable and displays the values of
both the variables after swapping.

19CS78
5

 Number1(num)  Processing items  num and num2


 Number2(num2)
num = num+num2;
num2 = num-num2;
num = num-num2;

 Algorithm
Step 01: start
Step 02: input num and
num2 from user
Step 03: calculate
num=num+num2;
Step 04: calculate
num2=num-num2;
Step 05: calculate
num=num-num2;
Step 06: print num and
num2
Step 07: End

Problem Statement 4
Write a program that asks the user to enter a four digit integer number and displays
the average of all the four digits of a number.

19CS78
6

 Number(num)  Processing items  Average of four digits


temp=num&10; (sum/4)
sum+=temp;
num=num/10;
Sum/4
 Algorithm
Step 01: start
Step 02: input num of four
digit from user
Step 03: repeat step 04 to 06
four times
Step 04: calculate
temp=num&10
Step 05: calculate
sum+=temp;
Step 06: calculate
num=num/10;
Step 07: print sum/4
Step 08: End

19CS78
7

Problem Statement 5
A person enters the bank and stands in the queue to get his salary. When his turn
comes, he requests the cashier that I need my salary with minimum notes and coins.
Write a program for the cashier that first asks the cashier to enter the salary amount
and then displays the number of notes and coins of (Rs. 5000, Rs. 1000, Rs. 100, Rs.
50, Rs. 20, Rs. 10, Rs. 5, Rs. 2 and Re. 1).

19CS78
8

 Salary amount  Processing items Notes of five thousand


f_thousand=amount/5000 Notes of one thousand
thousand=amount/1000; rupees
hundred=amount/100; Notes of one hundred
twenty=amount/20; rupees
fifty=amount/50; Notes of twenty rupees
ten=amount/10; Notes of fifty rupees
five=amount/5; Notes of ten rupees
two=amount/2; Coins of five rupees
 Algorithm coins of Two rupees
Step 01: Start amount
Step 02: calculate
f_thousand=amount/5000
Step 03: calculate
thousand=amount/1000;
Step 04: calculate
hundred=amount/100;
Step 05: calculate
twenty=amount/20;
Step 06: calculate
fifty=amount/50;
Step 07: calculate
ten=amount/10;
Step 08: calculate
five=amount/5;
Step 09: calculate
two=amount/2;
Step 10: print Notes of
five thousand
Notes of one thousand
rupees
Notes of one hundred
rupees
Notes of twenty rupees
Notes of fifty rupees
Notes of ten rupees
Coins of five rupees
coins of Two rupees
amount

Step 11: End

19CS78
9

19CS78

You might also like