Programming Fundamentals
Programming Fundamentals
Roll # : CTAI-040
Lab 01
1. Write pseudo code and flowchart to get temperature in fahrenheit as input and
convert it to kelvin.
1. Begin
2. Variables c, f, k
3. Input f
4. Set c = (5/9*f)-32
5. Set k = c + 273
6. Output k
7. End
Begin
A Variables c, f, k
Input f
Output k
Set c = (5/9*f)-32
End
Set k = c + 273 A
Write a pseudo code and flowchart to calculate the area of a circle with radius
taken as input.
1. Begin
2. Variables radius, area, pi
3. Set pi = 3.141
4. Input radius
5. Set area = pi*radius*radius
6. Output area
7. End
Begin
Set pi = 3.141
Input radius
End
Output area
A
Write pseudo code and flowchart to convert Km/hours in Miles/hours.
1. Begin
2. Variables kilometer, miles
3. Input kilometer
4. Set miles = kilometer/1.609
5. Output miles
6. End
Begin
Input kilometer
Output miles
End
Write a pseudo code, algorithm and flowchart to take hours and minutes as input
and then calculate the total number of seconds
1. Begin
2. Variables hours, minutes, onehour, oneminute, totalseconds
3. Input hours
4. Input minutes
5. Set onehour = 3600
6. Set oneminute = 60
7. Set totalseconds = (hours*onehour)+(minutes*oneminute)
8. Output totalseconds
9. End
algorithm
1. Begin
2. Initialize variables hours, minutes, onehour, oneminute and totalseconds as
integers
3. Take input value in hours
4. Take input value in minutes
5. Set the value of onehour = 3600
6. Set the value of oneminute = 60
7. Set the value of totalseconds = (hours*onehour)+(minutes+oneminute)
8. Print the value of totalseconds
9. End
Begin
A
Set oneminute = 60
End
Set totalseconds = (hours*onehour)+
(minutes*oneminute)
Output
totalseconds A
One of the jobs that Joe Roberts has been given at work is to order special paper
for a board meeting. The paper comes in reams of 500 sheets. He always makes
five more copies than the number of people that will be there. Joe wants to know
how many reams of paper he needs for a meeting. He can order only whole, not
partial reams. Assume the required number of pages will not equal an exact
number of reams. Test your solution with the following data: The report is 140
pages long and there will be 25 people at the meeting.
1. Begin
2. Variables people, pagesofoneream, pages, totalreams, totalpages
3. Input people
4. Input pages
5. Set people += 5
6. Set pagesofoneream = 500
7. Set totalpages = people * pages
8. Set totalreams = totalpages/pagesofoneream
9. Output totalreams
10. End
Begin
Set people += 5
A
Joe would like to build several bookcases that are of several heights and widths.
All will be 12 inches in depth. The bookcases will have three shelves, in addition
to the bottom and top. Write a solution to print the number of feet of 12-inch
wide boards that Joe will need to complete the bookcase, given the height and
the width.
1. Begin
2. Variables heightfeet, widthfeet, height, width, depthfeet, depth, hlength, vlength,
tlength
3. Input height
4. Input width
5. Set depth = 12
6. Set depthfeet = depth/12
7. Set heightfeet = height/12
8. Set widthfeet = width/12
9. Set vlength = heightfeet * 2
10. Set hlength = widthfeet * (3+1)
11. Set tlength = vlength + hlength
12. Output tlength
13. End
Begin
Input height,
width
Set depth = 12
Output tlength
End