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<=4; a++) {
for (int b=1; b<=5; 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 understand what u want to do..but what can i see is..u use function size to get the value of row and column..it is not global variable..its only local.so u should pass to other function if u want to use of it some more..so i cant see any use of that variable and its value in your program..