PDA

View Full Version : pascal help



thepretender
04-17-2009, 01:14 AM
does anyone know pascal? because i'm having trouble running a program code i made. It won't load?

SaveFerris
04-17-2009, 03:12 PM
You should probably post the code you're using, and be more specific with your problem.

Barbarossa
04-17-2009, 03:43 PM
Post the code already. I know a bit of pascal.

thepretender
04-18-2009, 09:48 AM
alright relax dudes..

PROGRAM Expressions1(OUTPUT);
BEGIN
WRITELN;
WRITELN('A. 15 - 15 DIV 15 = ',15-15 DIV 15);
WRITELN('B. 22 + 10 / 2 = ', 22+10/2:0:2);
WRITELN('B. (22 + 10) / 2 = ', (22+10)/2:0:2);
WRITELN('C. 50 * 10 - 4 MOD 3 * 5 + 80 = ',50*10-4 MOD 3*5+80);
WRITELN('Press ENTER to continue..');
READLN
END.

my problem is getting the "RUN" function to do its job and display the output program of the code.

bigboab
04-18-2009, 08:42 PM
alright relax dudes..

PROGRAM Expressions1(OUTPUT);
BEGIN
WRITELN;
WRITELN('A. 15 - 15 DIV 15 = ',15-15 DIV 15);
WRITELN('B. 22 + 10 / 2 = ', 22+10/2:0:2);
WRITELN('B. (22 + 10) / 2 = ', (22+10)/2:0:2);
WRITELN('C. 50 * 10 - 4 MOD 3 * 5 + 80 = ',50*10-4 MOD 3*5+80);
WRITELN('Press ENTER to continue..');
READLN
END.

my problem is getting the "RUN" function to do its job and display the output program of the code.


I don't know what version of Pascal you are using. I am only guessing what you are trying to achieve not having seen the exercise question. If you look at the modified program below(MS-DOS Pascal 6) it might give you an idea where you have gone wrong.

PROGRAM Expressions1(OUTPUT);
BEGIN
WRITELN;
WRITE('A. (15 minus 15) divided by 15 = , ');
WRITELN((15-15)/15);
WRITE('B. (22 plus 10) divided by 2 = , ' );
WRITELN((22+10)/2);
WRITE('C. (50 multiplied by 10 minus 4) divided by 3 multiplied by 5 plus 80 = , ');
WRITELN(((50*10)-4) MOD ((3*5)+80));
WRITELN('Press ENTER to continue..');
READLN
END.

When doing calculations always do your first calculation inside brackets e.g(10+2). Then add your second calculation enclosing both calculations in brackets e.g.((10+2) * 6) otherwise Pascal will calculate in the following order: *,/,-,+ and that won't necessary give you the result that you originally wanted;

10+2 * 6 = 22.

((10+2) * 6) = 72


Good luck.:)

thepretender
04-21-2009, 05:48 AM
Yep.. its more neat and spread out. Thanks!