Jump to content

Programming Language Help


Flim_Flam

Recommended Posts

I'm in a programming logic and design class. I had to work late last Tuesday and missed class and wasn't able to get ahold of anyone for class notes. I have an assigmnet due that states : "Use a For/Next Loop to calculate the average of 5 numbers" The chapeter we covered is on Arrays, so I'm assuming I'll need to use an array of some sort. All of our programs we write are just in Basic/Pseudocode. If anyone could help me out I'd appreciate it. I've been staring at the book for 2 hours and have not gotten anywhere.

Link to comment
https://www.mvpmods.com/forums/topic/32163-programming-language-help/
Share on other sites

My BASIC is a bit rusty, so here's some pseudo-code. It shouldn't take much to convert it to BASIC:

First, fill a 5 entry array with your values. Now, here's the pseudo-code to calculate the average:

Total = 0



FOR Count = 1 to 5

Total = Total + Array[Count]

Average = Total / Count

NEXT Count



PRINT Average
How's that? Alternatively, if you only want to calculate the average once, you could simply move the "Average = Total / Count" statement outside the FOR loop and simply use the statement "Average = Total / 5"
Total = 0



FOR Count = 1 to 5

Total = Total + Array[Count]

NEXT Count



Average = Total / 5

PRINT Average

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...