Professional Documents
Culture Documents
Bahria University (Karachi Campus)
Bahria University (Karachi Campus)
1. Design an algorithm to read a list of real numbers representing numeric scores, call functions
to calculate their mean and standard deviation, and then call a function to determine and
display the letter grade corresponding to each numeric score. Considering the following
equations and table for letter grade:
Here, m is the mean score and δ is the standard deviation; for a set of n numbers x1, x2, . . .,
xn, these are defined as follows:
x<m- F
m- δ<=x<m- D
m- δ<=x <m+ C
m+1δ<=x<m
+ B
2
m- δ<=x A
SOLUTION:
function mean()
function value()
{
o loop till (index < n)
o if ( data[index] < y)
write “f grade”
o if ( y <= data[index] and data[index]<y)
write “d” grade
o ” if (y <= data[index] and data[index] < z)
write “c grade”
o if ( z <= data[index] and data[index] < z )
write “b grade”
o if ( y <= data[index] )
write “a grade”
o
a) Maximum Value
b) Average
c) Product
1
SOLUTION:
MAX VALUE:
AVERAGE:
Create variable R and sum.
Repeat the node n times from the head node to tail node.
For i=0; repeat i till next.node = 0;
Add the value of each node in the variable sum i.e sum += R
Increment the value of loop
Divide the sum by the length of linked list and print average.
PRODUCT:
Create variable R and product
Repeat the node n times from the head node to tail node.
For i=0; repeat i till next.node = 0;
Multiply the value of each node in the variable product i.e product *= R
Increment the value of loop
Print the product.