Formatting an array and using global variables
Nov 5, 2014 at 5:12am UTC
I am confused as to how to format my array so that the output looks like a multiplication table. I am having trouble knowing where to put a "/n" or an "/t" or an "endl" somewhere. Also, any arguments passed to and from the function multiply_me have to use global variables only.
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
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
const int x = 11;
const int y = 11;
void multiply_me(int result_nums[x][y], int nums[]);
int j = 0;
int i = 0;
int main()
{
const int max = 11;
int mult[max] = {0,1,2,3,4,5,6,7,8,9,10};
cout<<"This program will output the multiplication tables for the integers 0-10" <<endl;
int result_mult[x][y];
multiply_me(result_mult, mult);
cout<<"0 1 2 3 4 5 6 7 8 9 10" <<endl;
for (i = 0; i<11; i++)
{for (j = 0; j<11; j++)
{cout<<result_mult[i][j];
}
}
cout<<"0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10" <<endl;
system("pause" );
return 0;
}
void multiply_me(int result_nums[x][y], int nums[])
{
for (i = 0; i<11; i++)
for (j = 0; j<11; j++)
result_nums[i][j] = nums[i]*nums[j];
return ;
}
Topic archived. No new replies allowed.