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

Programming Fundamentals

This document contains the solutions to several coding exercises in the form of pseudocode and flowcharts. It includes: 1) Converting temperature from Fahrenheit to Kelvin, 2) Calculating the area of a circle, 3) Converting between km/hr and miles/hr, 4) Calculating total seconds from hours and minutes input, 5) Calculating paper needs for a meeting based on attendees and page count, 6) Calculating board feet needed for bookcases of given heights and widths. The pseudocode includes variable declarations, input/output steps, and mathematical operations to solve each problem.

Uploaded by

Sabih Salam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Programming Fundamentals

This document contains the solutions to several coding exercises in the form of pseudocode and flowcharts. It includes: 1) Converting temperature from Fahrenheit to Kelvin, 2) Calculating the area of a circle, 3) Converting between km/hr and miles/hr, 4) Calculating total seconds from hours and minutes input, 5) Calculating paper needs for a meeting based on attendees and page count, 6) Calculating board feet needed for bookcases of given heights and widths. The pseudocode includes variable declarations, input/output steps, and mathematical operations to solve each problem.

Uploaded by

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

Name: Muhammad Sabih Salam

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

Variables radius, area, pi

Set pi = 3.141

Input radius

End

Set area = pi * radius * radius

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

Variables kilometer, miles

Input kilometer

Set miles = kilometer/1.609

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

Variables hours, minutes, onehour,


oneminute, totalseconds

Input hours, minutes

Set onehour = 3600

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

Variables pagesofoneream, pages, people,


totalpages, totalreams

Input pages, people

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

Variables height, width, heightfeet, widthfeet, depth,


depthfeet, vlength, hlength, tlength

Input height,
width

Set depth = 12

Set depthfeet = depth/12

Set heightfeet = height/12

Set widthfeet = width/12

Set vlength = heightfeet * 2

Set hlength = widthfeet * (3+1) K


K

Set tlength = vlength + hlength

Output tlength

End

You might also like