Do the necessary planning (IPO) and write an algorithm in pseudo code for the following:
1 An unknown number of toddlers are taking part in a competition. 5 adjudicators will give each competitor a mark out of 10. These marks are added together to get a mark out of 100. Write a complete C++ program to do the following
Enter the competitor’s number. (-1 is entered to terminate the input.)
Enter 10 marks out of 10 for each competitor.
Calculate the total mark.
Compare it to the marks of previous competitors to obtain the highest mark.
Enter the number of the following competitor.
When all data have been processed, display the number of the competitor with the highest mark as well as the current competitor’s mark.
int n \\ number of competitors
int array Sum(n) \\ array of total marks
{
for j from 1 to n
display 'Enter the competitor’s number':
int x
if x=-1 then
terminate input
array int A(10) \\ marks for competitor
Sum[x]=0 \\ initial total mark
display 'Enter mark out of 10 for competitor:'
{
for i from 1 to 10
A[i]=ai \\ enter 10 marks
int a
Sum[x]=Sum[x]+A[i] \\ calculate total mark
}
if x>1 then
M=max(Sum[x],Sum[x-1]) \\ compare to the mark of previous competitor
}
display 'the number of the competitor with the highest mark as well as the current competitor’s mark:'
Comments
Leave a comment