Algorithm and programming codes, Exercises of Computer Programming

this topic is about algorithm and programming codes

Typology: Exercises

2021/2022

Uploaded on 04/07/2022

garcia-kyla-mae-a
garcia-kyla-mae-a 🇵🇭

5

(1)

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Name: Kyla Mae A. Garcia
Course/Year/Section: BSIT-1B
Assessment 1
A. In three (3) sentences, in your own words, define and explain its
importance in programming.
- Programming is how we communicate with machines in a way that makes
them function how we need them to. It directs a computer to complete
commands so people do not have to do the task repeatedly. Also, a way to
understand codes.
B. Given the problems to be solved below, determine the needed input
and output variables.
1. Compute for the average grade of Student A in her five (5) major subjects.
Let:
a, b, c, d, and e represents the grade of student A in her 5 major subjects.
average= student A in her 5 major subjects.
•Input Variable/s: a, b, c, d, e
•Output Variables: average
Step 1: Start
Step 2: Initialize sum=0
Step 3: Input a, b, c, d, e
Step 4: Compute for the average,
average= a + b + c + d + e / 5
Step 5 : Print average
Step 6: End
2. Get the highest rating of the three (3) newly hired employees.
Let:
i, h, and j represents the ratings of the hired employees.
•Input Variable/s: i, h, j
•Output Variables: rating
Step 1: Start
Step 2: Initialize sum=0
Step 3: Check if I is greater than h using <,>
Step 3.1: If true, check if i is greater than j
Step 3.1 1: If true, print I as highest rating.
Step 3.1 2: If false, print j as highest rating.
pf2

Partial preview of the text

Download Algorithm and programming codes and more Exercises Computer Programming in PDF only on Docsity!

Name: Kyla Mae A. Garcia Course/Year/Section: BSIT-1B Assessment 1 A. In three (3) sentences, in your own words, define and explain its importance in programming.

  • Programming is how we communicate with machines in a way that makes them function how we need them to. It directs a computer to complete commands so people do not have to do the task repeatedly. Also, a way to understand codes. B. Given the problems to be solved below, determine the needed input and output variables.
  1. Compute for the average grade of Student A in her five (5) major subjects. Let: a, b, c, d, and e represents the grade of student A in her 5 major subjects. average= student A in her 5 major subjects.

•Input Variable/s: a, b, c, d, e

•Output Variables: average

 Step 1: Start

 Step 2: Initialize sum=

 Step 3: Input a, b, c, d, e

 Step 4: Compute for the average,

average= a + b + c + d + e / 5  Step 5 : Print average  Step 6: End

  1. Get the highest rating of the three (3) newly hired employees. Let: i, h, and j represents the ratings of the hired employees.

•Input Variable/s: i, h, j

•Output Variables: rating

 Step 1: Start

 Step 2: Initialize sum=

 Step 3: Check if I is greater than h using <,>

Step 3.1: If true, check if i is greater than j

Step 3.1 1: If true, print I as highest rating.

Step 3.1 2: If false, print j as highest rating.

Step 3.2: Else, check if h is greater than j.

Step 3.2 1: If true, print h as highest rating,

Step 3.2 2: If false, print j as highest rating.

 Step 4: End

C. Write the algorithm of the problems stated in B.1 and B.2:

  1. Compute the total amount to be paid by Customer X on the 7 products she ordered online. Let: a, s, d, f, j, k, l, and m represents the prices of the 7 products. sum= the prices of the 7 products  Step 1: Start  Step 2: Initialize sum=  Step 3: Input a, s, d, f, j, k, l, m  Step 4: Compute the total amount, sum= a + s + d + f + j + k + l + m
  • Step 5: Print sum
  • Step 6: End
  1. Compute for the average grade of Student A in her five (5) major subjects. Let: s1, s2, s3, s4, and s5 represents the average of Student A in her 5 major subjects.  Step 1: Start  Step 2: Initialize average=  Step 3: Input s1, s2, s3, s4, s  Step 4: Compute for the average, average= s1 + s2 + s3 + s4 + s5 / 5  Step 5: Print average  Step 6: End