1 2 3 4 5
2 3 6 8 10
3 6 9 12 15
4 8 12 16 20
your loops have no ends, ("end;"), the loops aren't nested, so you get nothing from statement "j=i*i", for your purposes i squared is not the object. You need loop (J) inside of bigger loop (i), and compute their extension (multiply j*i).
Since it's homework exercise, I won't make this answer explicit. I would use a 2-dimensional array and a nested set of for-loops to load it with values based on the indexes of the respective loops (outer loop goes to prime axis (1-dimensional), inner loop covers secondary axis which is two-dimensional.
not being an expert at pascal i found this link, which may help http://www.computing.net/answers/pr...
However, my concern is that the 3(which it seems like should be a four) in the second row doesn't seem to match the pattern...was this an error? Or did I miss the pattern.
:: mike
I'm sorry, you're right it should be a four. I guess I was typing to fast! The link did help a bit, but since this is a homework assignment and we didn't get to CLRSCR or CRT; I can't use it.
Also what it bugging me is that my table doesn't go 1 t 5 both ways. It goes 1 to 5 across and 1 to 4 down.
I'm saying this site discourages cheating by having us do your homework. I expect you to show your work, by posting the code you wrote. Your program doesn't need to to work (if it did you wouldn't be asking us), but it does have to show you're trying to work though the assignment, and not working us for your grade.
Okay this is my code so far. I know I'm completly wrong but I tried anyway. program (input, output); var i,j:integer; begin writeln; for i:= 1 to 5 do write (i:5); writeln; for i:= 2 to 4 do writeln (i:5); writeln; j:=i*i; write (j:5); writeln; end.
your loops have no ends, ("end;"), the loops aren't nested, so you get nothing from statement "j=i*i", for your purposes i squared is not the object. You need loop (J) inside of bigger loop (i), and compute their extension (multiply j*i).
Okay so this is what I got after following your advice. I got the right numbers, but I don't know how to put it in the table layout. program (input, output); var i, j : integer; begin for i:= 1 to 5 do begin for j:= 1 to 4 do write(i*j:5); end; end.
program MulTab (input, output); var i, j : integer; begin for i:= 1 to 5 do begin writeln; for j:= 1 to 4 do write(i*j:5); end; end.
This is what I got after about a half hour. Thank you guys for your help. program (input, output); var i, j : integer; begin for i:= 1 to 4 do begin for j:= 1 to 5 do write(i*j:10); writeln; end; end.
See? we knew you could do it... We had confidence in you when you did not. good job! ;-)
{ email:tollyfather@gmail.com
multiplication program in pascal
}
program ass8;
var i,j,store:integer;
const tab=#9;
begin
for i:= 1 to 10 do
begin
for j:= 1 to 10 do
begin
store:= i*j;
write(store,tab);
end;
writeln();
end;
end.
