I am a beginner to C and I want to write a program to generate the following table but i am at a loss can anyone pls help me out with some source code.
1 2 3 4 5 6
1 1 2 3 4 5 6
2 2 4 6 8 10 12
3 3 6 9 12 15 18
4
5
6
7
8
9
10
11
12
sort of like a multiplication table
Comments
: following table but i am at a loss can anyone pls help me out with
: some source code.
: 1 2 3 4 5 6
: 1 1 2 3 4 5 6
: 2 2 4 6 8 10 12
: 3 3 6 9 12 15 18
: 4
: 5
: 6
: 7
: 8
: 9
: 10
: 11
: 12
: sort of like a multiplication table
:
That is not any multiplication table I've ever seen. :-)
Conversation should be pleasant without scurrility, witty without affectation, free without indecency, learned without conceitedness, novel without falsehood.
William Shakespeare
1 1 2 .. 10
2 2 4 .. 20
3 3 6 .. 30
.. .. .. ..
10 10 20.. 100
The dots stand for the numbers in between so that you can read of the table say 1*2=2.
[code]
| 1 | 2 | [color=Blue]3[/color] | 4 | 5 |
| 2 | 4 | 6 | 8 | 10 |
| 3 | 6 | 9 | 12 | 15 |
| [color=Blue]4[/color] | 8 | [color=Red]12[/color] | 16 | 20 |
| 5 | 10 | 15 | 20 | 25 |
[/code]
It's a multiplication table:
[color=Blue]3[/color]*[color=Blue]4[/color]=[color=Red]12[/color]
[code][blue]============================[/blue]
[red]THANK YOU AND GODBLESS !!!
from playagain[/red]
[blue]============================[/blue][/code]
: following table but i am at a loss can anyone pls help me out with
: some source code.
You need two nested loops that range from 1 to the maximum number you want to display in the table. For example the outer loop can use an i counter and the inner loop a j counter. Then use the printf() function to display the two counters multiplied together, for example
printf("%d ", i*j);
Conversation should be pleasant without scurrility, witty without affectation, free without indecency, learned without conceitedness, novel without falsehood.
William Shakespeare
Its in C++(I don't like C!).
[code]#include // system()
#include
#include // setw()
using namespace std;
int main(int argc, char *argv[])
{
system ("cls");
for (int i=1; i<11; i++)
{
cout << setw(4) << i;
for (int j=1; j<11; j++)
cout << setw(4) << i*j;
cout << endl;
}
system ("pause");
return 0;
}[/code]
--------------------------------------
- I don't have Time To waste The Time!