I am trying to create a subtraction table where you subtract the number of column from the number of row, and the answer appears within the table. For example if it is the 3rd row down, and the 2nd column over, then the answer is 1
# include <iostream>
# include <iomanip>
usingnamespace std;
//Function size-Tells user to enter number of rows and columns.
void size (int&row, int&column) {
cout<<"Enter number of rows:";
cin>> row;
while (row < 1 || row > 12) {
cout<<"Invalid number."<<endl;
cout<<"Enter number of rows:";
cin>> row;
}
cout<<"Enter number of columns:";
cin>> column;
while (column < 1 || column > 9) {
cout<<"Invalid number."<<endl;
cout<<"Enter number of columns:";
cin>> column;
}
}
//Function subtraction-Subtracts b from a
int subtraction (int a, int b) {
int diff;
diff = a - b;
return diff;
}
//Function show--displays the bars needed to create a table
void show ( ) {
int answer;
cout<< "___________________"<< endl;
for (int a=1; a<=5; a++) {
for (int b=1; b<=4; b++) {
answer = subtraction(a,b);
cout << subtraction(a,b);
}
cout<< a << "|" << answer <<endl;
}
}
//Main function-calls other functions.
int main ( ){
int row, column;
size(row, column);
show( );
return 0;
}
i dont know wat are u trying to do..
and u dont even use any global variable..
u ask the value of row and column from function size..
but then u use of it nowhere..
even in show or substract u're not using that variable