This is a VB Code
Sub main()
Dim i As Integer
Dim j As Integer
Dim k As Integer
For i = 1 To 10
Debug.Print
For j = 1 To i
Debug.Print j * i;
Next j
Next i
End Sub
In C
main()
{
for (i=1; i<=10; i++)
{
for (j=1; j<=i; j++)
printf ("%d", i*j);
printf("\n");
}
getch();
return 0;
}
2006-09-01 19:29:44
·
answer #1
·
answered by hanybakir 1
·
1⤊
0⤋
In case you are just interested in the program and not learning C you could use the following program
#include
int main()
{
printf("\n");
printf("\n");
printf("1\n");
printf("2 4\n");
printf("3 6 9\n");
printf("4 8 12 16\n");
printf("5 10 15 20 25\n");
printf("6 12 18 24 30 36\n");
printf("7 14 21 28 35 42 49\n");
printf("8 16 24 32 40 48 56 64\n");
printf("9 18 27 36 45 54 63 72 81\n");
printf("10 20 30 40 50 60 70 80 90 100\n");
printf("\n);
printf("\n);
printf("\n);
printf("please do help me.. huhuhu\n");
return 0;
}
or else you can go and learn C and do it urself. Believe me its more fun that way.
2006-09-01 23:26:25
·
answer #2
·
answered by Amrendra 3
·
0⤊
0⤋
I think the last answer is a little confused. There's no squaring going on here.
However, you do want to use two for loops. An outer loop and an inner loop. The outer loop has two effects on the inner loop: it determines the "step" or "increment" used in the inner loop, and also determines the number of repetitions that the inner loop performs.
So, start by just writing the inner loop by itself, and write it so that it will produce a single line of the output. When that's done, put the outer loop around it, and use the outer loop variable to control the inner loop.
2006-09-01 18:19:16
·
answer #3
·
answered by arbeit 4
·
0⤊
0⤋
I won't attempt to give you valid C code, but here is an algorithm in semi-pseudo code
for (a = 1; a <=10; a++){
for (b = 1; b <= a; b++){
print a * b + "\s"; //the plus here is for string concatanation not mathematical addition
}
print "\n";
}
2006-09-01 18:25:58
·
answer #4
·
answered by sterno73 3
·
0⤊
0⤋
through fact the undertaking is declared, i could bypass with the brute-stress approach of sorting out each and each variety interior the variety. however the sieve is plenty extra exciting, extraordinarily once you artwork out the thank you to partition the sieve so as so you might use assorted threads to parallelize the undertaking without having to apply any form of mutex. I wrote and examined approximately fifty diverse optimizations for the nth top difficulty utilising a sieve. the common, marvelous-basically sieve took approximately 5 thousand milliseconds (5 seconds) to discover the thirty millionth top, my very final, parallel version famous the thirty millionth top in approximately 172 milliseconds and makes use of roughly 6% of the RAM required with the help of the faster version. additionally thrilling to word that a great chew of overall performance comes from expertise the cache shape of your CPU - utilising somewhat array (to your sieve) boosts overall performance (even nevertheless you like extra code to do bit indexing) through fact it leads to fewer cache misses.
2016-11-23 18:36:11
·
answer #5
·
answered by ? 4
·
0⤊
0⤋
Try this code
# include
int lc, rc;
// lc = Line counter, rc = row counter
main()
{
clrscr();
for (lc=1; rc<=10; lc++)
{
for (rc=1; rc<=lc; rc++)
printf ("%d ", lc*rc);
printf("\n");
}
getch();
return 0;
}
------ Edited back
Seems the algorithm of “hanybakir” is the same as mine. Anyway, he’s first. I think the initial credit must go for him! I took too much time to build the program.
2006-09-01 20:23:32
·
answer #6
·
answered by Nishan Saliya 4
·
1⤊
0⤋
use 2 for loops I and J assign value 1 and 1
i loop
t=i [t => temp]
j loop
print t*t value
if j> i
exit j loop
t++
j loop close
i loop close.
2006-09-01 18:10:58
·
answer #7
·
answered by royal 3
·
0⤊
1⤋