trying my hand at pascal.

Status
Not open for further replies.

joshd

Fully Optimized
Messages
2,133
i have made this:


program AreaOfCircle (input, output);
const
pi = 3.1415926535897932384626433832795;
var
radius : real;
area : real;
procedure pause;
begin
writeln('press any key to exit');
readln;
end;

begin
writeln('enter radius:');
readln(radius);
area := pi * radius * radius;
writeln(area);
pause;

end.


is there an easier way to make the "pause" so the program doesnt't just exit itself after caluclating the value, not giving you a chance to read it? also, how do make it so it does not give the value in standard form, like it is doing at he moment?

thanks.


EDIT: i have added more functionality:

program AreaOfCircle (input, output);
const
pi = 3.1415926535897932384626433832795;
two = 2;


var
radius : real;
area : real;
volume : real;
circumference : real;



procedure pause;

begin
writeln('press any key to exit');
readln;
end;



begin
writeln('enter radius:');
readln(radius);
writeln;
writeln('circumference of circle =');
circumference := 2 * pi * radius;
writeln(circumference);
writeln;
writeln('area of circle =');
area := pi * radius * radius;
writeln(area);
writeln;
writeln('volume of sphere =');
volume := 4 / 3 * pi * radius * radius * radius;
writeln(volume);
writeln;
pause;

end.


the circumference does not work. it just outputs the value of pi. i have no idea why it does that.... :\ like so:



i have tried with the number "2", and having 2 as a constant, and neither way works, it just gives me pi.

EDIT EDIT: the circumference has now randomly started working... i didn't even change anything... :confused:

i am quite proud of that, i have only been coding for 2 hours.

EDIT EDIT EDIT: ok, there was never a problem with the circumference, it was just the numbers i was using.

i just want to know how to non-standard form it now. :)
 
Status
Not open for further replies.
Top