# Table Homework

• 09-23-2005
howeezy
Table Homework
I have to make this table for my class:
Enter num1:
Enter num2(must be greater than 16):
output:
num1 num2 num3 sum1 sum2 prod1 prod2 quot1 quot2 rmd
2 20 20 22 22 40 40 0 0.1 2
6 16 16 22 22 96 96 0 0.375 6
^ (this num gets multiplied by 3 everytime) and going on for 3 more lines

Is this going to be very long to write? Do I have to define a variable for each line? I am EXTREMELY new to this, please help :( .

This is what i have so far:
Code:

```  #include <iostream>  #include <string>  using namespace std;  int main()  {  //DEFINITIONS  cout << "Please enter the first number: ";  int num1;  cin >> num1;    cout << "Please enter the second number (greater than 16): ";  int num2;  cin >> num2;  float num3;  num3 = (float)num2;  float sum1;  sum1 = num1 + num2;  float  sum2;  sum2 = num1 + num3;  float prod1;  prod1 = num1 * num2;  float prod2;  prod2 = num1 * num3;  float  quot1;  quot1 = num1 / num2;  float quot2;  quot2 = num1 / num3;  float  rmd;  rmd = num1 % num2;    // TABLE cout << "Num1 Num2 Num3 Sum1 Sum2 Prod1 Prod2 Quot1 Quot2 Rmd ";  return 0;   }```
• 09-23-2005
Hammer
C++ ? Moving to the relavant forum.
• 09-23-2005
Enahs
I am not sure what the question is?

You seem to have all the code there, it might not be the neatest or most efficient, but it does what I think you said it has to do.

Other then output the numbers properly, what is left?
• 09-23-2005
howeezy
sorry this class is so fast I'm just really confused.

If i made this table wouldnt it need more than one input for num1? The instructions are so vague.

Or would I have to create a second num1?
• 09-23-2005
Enahs
So you want to repeat everything over, and each time it repeats multiply the original number by 3? You want loops.

http://www.cprogramming.com/tutorial/lesson3.html

```#include <iostream> using namespace std; int main() {         int number;         int counter = 0; //This gets incremented by one, counts how many times it has been repeated.         int calculation1, calculation2;         cout << "Enter a number: ";         cin >> number;         do         {         calculation1 = (number + number);         calculation2 = (calculation1 * number);         cout << "The numbers are: " << number << " " << calculation1 << " " << calculation2 << endl;         number = (number * 3);         counter++;         }while ( counter <= 5); //5 is a arbitrary number, it can be any hardcoded number or a variables.    return 0; }```