Arrays

i want to create a program that generates a multiplication table and the user can set his own peramiters
my problem is this
1
2
3
4
5
6
7
                     int i;
                     for (i = 1; i < Number; ++i)
                     {
                          cout << " " << Output[i];
                     }
                     
                     

for this code i wold like to use an array so that i can use the numbers to generate the rest of the map

i want to know how to make it so that the numbers in the array arnt all diffrent numbers without having to set all of them each indvidualy myself like this


double array[] = {1, 2, 3, 4, 5, 6, 7............}
i would like to know if it is better to use an array and set the nubers individual or should i get rid of the array all together and and if so what would be a better way to do it


heres my whole code if you need it:
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
#include <iostream>
using namespace std;
int main()
{  
    double Number;
    double Output[200];
   
    cout << " Pick the number your times table will go up to " << endl;
    cout << " it cant be greater then 200" << endl;
    cin  >> Number;
         if ( Number > 200 )
         {
              cout << " That number is to high ";
              main();
         }
       
                     int i;
                     for (i = 1; i < Number; ++i)
                     {

                         Output[i] = Output[i-1] + 1;   // new code
                          cout << " " << Output[i];
                     }
                     
    system("pause");
    return 0;
    
}





Last edited on
got it the array part

Output[i] = Output[i-1] + 1;

now i still need help with making the rest of the the times tables and to know if the way i am trying is good or if there is a better way


Last edited on
i got it now i am having trouble with my code
here is my code
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
using namespace std;



int Grid(double Number);

int main()
{  
    double Number;
    bool Run = true;
    char DoAgian = 'y';
   
    
    while(Run)
    {
 
    

   
              cout << " Pick the number your times table will go up to " << endl;
              cout << " it cant be greater then 100" << endl;
              cin  >> Number;
              if ( Number > 100 )                             
              {
                   cout << " That number is to high ";
                  main();
              }else
              { 
                   Grid(Number);
                   
                   switch(DoAgian)
                   {
                                  case 'y':
                                       break;
                                  case 'n':
                                       Run = false;
                                       break;
                                  default:
                                          cout << " Invalid Responce " << endl;
                   }
                   
                   
   }
       
                     
                     
                     
                     
    system("pause");
    return 0;
    
}




int Grid( double Number )
{
int i = 1;
int i2 = 1;
double Output;
double Number2;


      Number = Number2 ;
       
    
   while (Loop)
    {
          
          
          i = 1 + i2;
          Output = i; 
          if ( i == Number2 )
          {
               Loop = false;
          }         
          for( i = 1; i <= Number; i++ )
          {
               Output++;
               if ( Output >= 10 )
               {
                    cout << "  " << Output;
                    }else{
                          cout << " " << Output;
                          }
          }
          
          cout << endl;
          Number++;
          i2++;
          
    }
}
                          
               




it will not exit the loop
Last edited on
Topic archived. No new replies allowed.