Table of Subtraction

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

Something like this: http://www.mathatube.com/images/times-_and_division_table_chart-7.gif , except I only need mine to go to display 4 rows and 5 columns.

Currently it seems to format wrong, Can anyone help me?
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

# include <iostream>
# include <iomanip>
using namespace 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..
Topic archived. No new replies allowed.