i need help fixing this pascal program

Status
Not open for further replies.

shiftyape

Honorable
Feb 23, 2013
48
0
10,580
0
program whileloop;

var
x:integer;
answer:string;
num:integer;

begin

num:=12345;

writeln('type "12345" if you would like to see nubers squaring up to 4096');
readln(answer);

if answer = num then
begin
writeln('press enter to see the numbers');
readln;
end;

else begin
x:=0;
end;

x:=1;

while x < 4097 do
begin
writeln(x,' squared is now ',x*x);
x:=x+1;
end;

writeln;
readln;

end.


this is the error i keep getting: whileloop.pas(29,2) Fatal: Syntax error, ";" expected but "ELSE" found
and also: whileloop.pas(23,14) Error: Incompatible types: got "LongInt" expected "AnsiString"
 

Ijack

Distinguished

You really are an ungrateful little *****, aren't you. You post a homework assignment and then are rude to the person who takes the trouble to help you.

Take a different course - computer programming is obviously not for you.
 

ex_bubblehead

Distinguished
Moderator
So many things wrong here....

And, since this looks suspiciously like a homework assignment, I'm not going to simply hand you the solution.

Just for starters:

1. You're looking for equality between a string and an integer
2. You've used ';' in places you shouldn't
3. Your routine has no proper exit, or structure, for that matter. No matter what you choose it falls through and squares the numbers. You have code in there that is better moved into a procedure.
 

shiftyape

Honorable
Feb 23, 2013
48
0
10,580
0


oh, wow, ive incited the rage of some random guy. who cares. if you did not come to this post to help, why did you answer at all? by the way this is my first day of trying to learn pascal, so sorry if its not some majestic and amazing program. it tends to take a few days to learn the basics. and no, this is not a school assignment, im doing this on my own free time, and people like you who criticize dont really encourage me that much. im just saying this because this is not the first negative feedback ive received today. go and bug someone else
 

Ijack

Distinguished

You really are an ungrateful little *****, aren't you. You post a homework assignment and then are rude to the person who takes the trouble to help you.

Take a different course - computer programming is obviously not for you.
 

Hawkeye22

Distinguished
Moderator
You could probably google for answers, but if you are trying to learn on your own, I suggest you go out and purchase a beginners guide to programming pascal.

writeln expects a string, x*x is not a string, it's numeric. Googling "pascal if else statement" should yield your other answer. We can't give you all the help, or you won't learn from it. ;)
 

shiftyape

Honorable
Feb 23, 2013
48
0
10,580
0


wow. i never thought a simple question could yield an angry person swearing at me over something it took someone 1 minute to type. this is the age of the internet i guess. i realize i was rough on the guy to first post, and his post did help me, so i must say im sorry to him. i am just frustrated at all the negative feedback i have received since asking questions about pascal online. i will try something else.
 

shiftyape

Honorable
Feb 23, 2013
48
0
10,580
0


i am very sorry, my friend. just struggling to get real answers in the land of the internet. i apologize. thank you for your feedback
 

Ijack

Distinguished
Let's hope you learn some manners quicker than your programming skills are progressing. You are going to get a real shock when you grow up enough to look for a job and have to interact with others.
 

BaldrGeek

Honorable
Mar 24, 2013
3
0
10,510
0
oh, wow, ive incited the rage of some random guy. who cares. if you did not come to this post to help, why did you answer at all?
He was trying to help, which is what I had come here to do. He gave you some useful advice, like "you are comparing numbers with strings".

You can only help people that want to be helped. And in your case, you don't want help, you just want an excuse to act like a jerk.
 

ex_bubblehead

Distinguished
Moderator

I'll take this under advisement. However, in the future it would behoove you to accept constructive criticism with a great deal more graciousness, especially when you're the one asking for the assistance, otherwise you'll find it a very rough road ahead.
 

shiftyape

Honorable
Feb 23, 2013
48
0
10,580
0


ok, you guys, i apolagized, can we just drop this
 

Hawkeye22

Distinguished
Moderator
I'm glad this came to a peaceful solution. Always think before you speak/write. We are all here to learn and assist others. Since a best answer was chosen and apologies were made, I'll close this topic.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
C Apps General Discussion 1
ConorChaos Apps General Discussion 0
David___Only Apps General Discussion 0
kikani.kautik Apps General Discussion 2
I Apps General Discussion 5
G Apps General Discussion 1
V Apps General Discussion 2
M Apps General Discussion 3
M Apps General Discussion 1
W Apps General Discussion 1
K Apps General Discussion 1
O Apps General Discussion 2
G Apps General Discussion 1
K Apps General Discussion 2
S Apps General Discussion 1
S Apps General Discussion 4
A Apps General Discussion 1
mprospero Apps General Discussion 4
S Apps General Discussion 2
T Apps General Discussion 17

ASK THE COMMUNITY

TRENDING THREADS