cc++

Programing Questions

An algorithm has been written in pseudocode to input the names and marks of 35 students. The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest mark awarded is found and the number of students with that mark is counted. Both of these values are output.

A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number of baskets. The total weight is stored in a variable Total and the number
of baskets is stored in a variable BasketCount.
Explain, including examples of programming statements, how totalling and counting could be used
in this program.

The following pseudocode algorithm uses nested IF statements.
IF Response = 1
THEN
X X + Y
ELSE
IF Response = 2
THEN
X X – Y
ELSE
IF Response = 3
THEN
X X * Y
ELSE
IF Response = 4
THEN
X X / Y
ELSE
OUTPUT "No response"
ENDIF
ENDIF
ENDIF
ENDIF

a). Name the type of statement demonstrated by the use of IF … THEN … ELSE … ENDIF

b). Re-write the pseudocode algorithm using a CASE statement.


Shares:

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.