0% found this document useful (0 votes)
1 views1 page

Nested Loop

The document outlines a program that calculates and outputs the total and average marks for a class of 10 students across 3 subjects. It uses nested loops to gather marks for each subject per student and aggregates the results. Finally, it provides the total and average marks for all students combined.

Uploaded by

furryfbi2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Nested Loop

The document outlines a program that calculates and outputs the total and average marks for a class of 10 students across 3 subjects. It uses nested loops to gather marks for each subject per student and aggregates the results. Finally, it provides the total and average marks for all students combined.

Uploaded by

furryfbi2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

classSize  10
2. numSubject  3
3. classTotal  0
4. FOR student  0 TO classSize-1 DO//to get marks from 10 students
a. subjectsTotal  0
b. FOR subject  0 TO numSubject -1 DO// to get individual subject mark; here is 3
c. OUTPUT “Please enter mark for subject ”, subject+1,”:”
d. INPUT mark
e. subjectsTotal  subjectsTotal + mark // to sum up all subject marks for each
student
f. NEXT subject
g. OUTPUT “Total marks for student”,student+1,”:”,subjectsTotal
h. OUTPUT “Average mark for student”,student+1,”:”,subjectsTotal/numSubject
i. classTotal  classTotal+subjectsTotal//totalling all students mark
5. NEXT student
6. OUTPUT “Total marks for all students: ”, classTotal
7. OUTPUT “Average mark for all students:”,classTotal/classSize

Nested loop: loop inside another loop: for/while/repeat-until

You might also like