Output Function ? Who can get me started? /:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <iomanip>
using namespace std;
// PrintSquaresAndCubes.cpp

/* Sample Output

NUMBER   SQUARE   CUBE
------   ------   ----
  2         4        8
  3         9       27
  5        25      125
  7        49      343
  8        64      512


*/


int main()
{
   // prototype
   void printSquaresAndCubes(int number);

   // headings
   cout << endl;      // print a blank line
   cout << "NUMBER   SQUARE   CUBE\n"
        << "------   ------   ----\n";

   // function calls
   printSquaresAndCubes(2);
   printSquaresAndCubes(3);
   printSquaresAndCubes(5);
   printSquaresAndCubes(7);
   printSquaresAndCubes(8);

   cin.get();
   return 0;
}

//-------------------------------------------------------------------
// Output Function - code the printSquaresAndCubes() function below
// parameters: number :  int
// returns: none
//------------------------------------------------------------------- 
Last edited on
What are you looking for? All you did was post code.

Anyways void printSquaresAndCubes(int number); is invalid. You can't prototype inside a function. Anyways you never made the the function you call on 31-35..

[edit]I guess you can put prototypes inside of functions though I think it would be best near you headers.
Last edited on
Thats what im trying to figure out the assignment is find the Output Function, so i need to - code the printSquaresAndCubes() function below
// parameters: number : int
// returns: none
basically im trying to figure out the missing output function to make the code work..same goes on the other one
We won't write it for you. Attempt to write it and if you have questions about it let us know. Posting an assignment with no information is hardly asking for help.
will if I had an example of one it be a lot easier..; i'm simply struggling in this class not soo much because I dont understand what the code does, but my problem is simply trying to generate code.


1
2
3
4
5
6
7
8
const int printSquaresAndCubes ()

{
 int sqrt = sqrt 
 cout << Enter square root number. " ;
 cin >> printSquaresAndCubes;

} 



ok thats all I could think of and I know I'm not even close, truth is I really have no idea where to start and I just suck at this and hate this class...
Last edited on
I have about 5 more of these to do is the sad thing...so if I can at least see how one is done properly I can at least try to get really going on the others....
const int printSquaresAndCubes () does not match the prototype of void printSquaresAndCubes(int number); anyways it doesn't want you to enter a number none the less a random sqrt. It takes an paremeter of x and then ouputs the sq and cube of it.

1
2
3
4
void printSquaresAndCubes(int x)
{
    std::cout << x << "   " << x*x << "   " << x*x*x << std::endl;
}
Last edited on
ok.....so you simply called x to be the printSquaresAndCubes int number and output the number, and than next output the number times itself to get the sq rt and, than thirdly multiply by itself 3 times to get the cubed right..? This makes complete sense...!! THANK YOU..!!! Ill try the others now and let me know what you think...you've been most useful giblit...(:
Yes. X is the number being passed to the function:
1
2
3
4
5
   printSquaresAndCubes(2); //x = 2
   printSquaresAndCubes(3); //x = 3
   printSquaresAndCubes(5); //x = 5
   printSquaresAndCubes(7); //x = 7
   printSquaresAndCubes(8); //x = 8 
Topic archived. No new replies allowed.