PDA

View Full Version : C++ help please!



Vash02
04-22-2003, 04:45 PM
Okay i need help from you smart people out there. I need a complete c++ program for the following problem.

Write a complete program to produce a chart consisting of the multiples of 5 from -50 to 50 together with the squares and cubes of these numbers. Use a function to print a suitbale heading and user-defined functions for square and cube.


Thanks alot. Im in my second qrt. of this stuff and this one is driving me nuts.

gimp
04-22-2003, 05:33 PM
well, i'll give you some ideas of how I'd do it. It's just pseuodocode, but you get the idea.



********************main function
print("number squared cubed")

for i = -10 to 10
num = i*5;
print(num, square(num), cube(num) )
end for loop




*******************square function***********
int square(x)
return (x*x);

*******************cube function************
int cube(x)
return (x*x*x)

Kevmaster
04-22-2003, 06:41 PM
or not psuedo code:

#include <iostream>
using namespace std;

int main() {
-for (int a = -50; a < 50; a+=5) {
--cout << "Number: "<< a ;
--cout << ", Square: " << (a*a);
--cout << ", Cube: " << (a*a*a) ;
--cout << endl;

-}
}


the "-" and "--" represent indentations
the actaul headers and main declaration may vary based on your compiler, Im using Metroworks Code Warrior

Vash02
04-22-2003, 07:10 PM
Thanks alot to the both of you...i may need to call upon you again in the future.

impostal22
04-22-2003, 09:29 PM
is this c++ course in highschool or college? just curious.

Kai
04-22-2003, 09:46 PM
Jeff, you lazy piece of crap.

Now you are only behind, what...16 assignments?

Vash02
04-23-2003, 07:47 PM
Its not that im lazy..i hoestly dont understand this program.

And by the way ryan..........im only down 14!!

P.S. this is a high school course..and i hate it. Im not cut out for programming.

Vash02
04-23-2003, 07:48 PM
By the way, i noticed your back to the lennon sig ryan.

Brak
04-23-2003, 08:33 PM
Originally posted by Vash02
By the way, i noticed your back to the lennon sig ryan.


off subject, but itsnt he lennin? i chose stalin over him for a report...

pbzmag
04-23-2003, 11:59 PM
Originally posted by Vash02
P.S. this is a high school course..and i hate it. Im not cut out for programming.

Is it an elective class? I took Pascal in my Junior year as this was the only programming class offered. Personnally, I found programming easy to understand. For some people, it comes easy for them and for other's, it takes time for them to have it hit them on the side of the head to finally understand the logic. I took CIS in college and there were a few people who didn't understand the logic until the the 3rd year. Most classes were in DOS and legacy systems and 2 were Windows based. If you're thinking about a career in computers, hang in there. You'll have a small advantage over others who have gone into it, with no knowledge, for the high salary. Heck, I didn't even get a job doing programming. I went for pc/network support.

impostal22
04-24-2003, 09:56 AM
i took a course in C++ last year (my junior year in high) and now i'm taking a college level c++ course in my senior year, and i really like it. problem is, i dunno what the hell i'm gonna do w/ the programming talent i have, because from what i hear the need for programmers/etc isn't what it used to be...:rolleyes: