Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I have included a photo of my Chapter 9 Assignment. It is not due till next Monday since it is Spring Break but I want to do it before I forget.

1. The goal is to use Functions to solve the problems
2. I have to write my own Top Down Design
3. I have to sum a cube?

He wrote this on the board when he explained it.
sqrsum := a*a + b*b + c*c + d*d

The example on the paper use 10 10 10 20 and that returned 11000. But when I so 10*10 + 10*10 + 10*10 + 20*20 I come to a total of 700. I am not understanding this conversion?
Code:
the code he used on the board

function sqrsum (A,B,C,D : integer) : integer
begin
    sqrsum := a*a + b*b + c*c + d*d
.
.
.

How do you find the sum of a cube?

Thanks,

-Lars
 

Attachments

  • chap9.jpg
    chap9.jpg
    192.5 KB · Views: 211

dukebound85

macrumors Core
Jul 17, 2005
19,131
4,110
5045 feet above sea level
Your function example is a sum of squares, hence the a*a +b*b etc

Sum of cubes is a*a*a +b*b*b etc and that will give your 11k as per what he got

For your assignment, my approach would be to have 3 variables set to sum of squares, sum of cubes, and mean of squares and print out the desired variable to give your answer if the integers are within the desired range
 
Last edited:

SidBala

macrumors 6502a
Jun 27, 2010
533
0
Aah yes. First year computer courses. I wish I was back there.

This year, my next assignment is to write what will pretty much be a complete game engine in less than a week. :(

Anyway, you just need to follow the directions on the assignment page.

Have 3 functions that return the appropriate values and setup the keyboard input with a switch case. Then call and print appropriate function/value.
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Thanks for the help in understanding the Sum of a cube and the push in the right direction. I will start on it tomorrow night.

This is the first assignment that I have to produce my own Top Down Design. The projects before this He would do them on the board and we would copy them down. I'll have to go over my notes on the last projects to get a better handle on it.

Thanks Guys!

-Lars
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I am happy I got ubuntu Linux running under Parallels. It almost emulates the Lab version except for FPC not working correctly for compiling. But terminal works great using GPC. I should be starting on this tonight, with my Top Down Design.

-Lars
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.