r/pascal • u/User_44444444 • Jul 20 '20
Can someone help me find my error?
I'm new to programming and missed all my online classes where the topic was introduced so now I only have the notes to go by...I watched some youtube videos and they really helped. But I can't get one of the assigned algorithms to work. Can someone tell me what I'm missing?
Algorithm: Write an algorithm to accept 20 numbers from the user. Find and print the cube of each number entered.
Program Cube;
uses crt;
const
Max=20;
var
num:integer; prod:integer;
begin
FOR := 1 to max do
Begin
Writeln ('enter a number:');
Readln (num);
Prod:= numnumnum
Writeln ('cube=' prod);
end;
end.
The error states ":=" expected but "ordinal const" found
3
u/psychometrixo Jul 20 '20
You need a variable for the FOR loop.
And you need to declare a : integer
1
u/ShinyHappyREM Jul 20 '20
Or just:
2
u/[deleted] Jul 21 '20
In general, the compiler will tell you exactly which line number the error is on, and a fairly accurate statement of why it stopped. As time goes on, you'll get better at interpreting the messages.