Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using VBA Write a program that prints the sum of the squares of the numbers from

ID: 3675883 • Letter: U

Question

Using VBA

Write a program that prints the sum of the squares of the numbers from 1 to 99.

Hints: Statements like sum=sum+n^2, n=n+1, and IF (n>maxNumber) … might be useful inside the loop. While a statement like n = n+1 makes no mathematical sense it makes good computational sense. A line of computer code is not a statement of truth, rather, it is a sequence of instructions. By convention these instructions are read from right to left (backwards.) The statement "n = n +1" does NOT mean "it is true that n equals n+1" to a computer; instead it instructs the computer (reading backwards) to "add 1 to the value referred to by the name n then assign the resulting value to n." If old typewriters had the left arrow character the syntax would probably be " nn+1" which is much closer to what's actually happening.

Explanation / Answer

Dim Num As Integer

Dim Sum As Integer

For i = 1 to 99

Sum=Sum+Num^2;

Num=Num+1;

Print Sum;

End Loop

Next

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote