ok, im making a basic program in pascal. like a text based calculator (i dont know how to make GUIs) so lets say i have a peice of code like this:

program test;
var
A,B,C:real;

begin
  writeln('enter the first number');
  readln(A);
  writeln('enter the second number');
  readln(B);
  C:=A/B;
  writeln('your answer is: ',C);
End.

when i do this, it displayes the decimel in scientific notation (EX 50.00 woiuld be 5.000000000E+001) witch alot of people dont know how to read scientific notation. is there anyway to convert this into a decimel that people are used to like 104.00 ?

Yes. For some oddball reason it isn't in any of the Delphi docs that I've ever seen, but you can specify width and precision for floating point variables:

var foo: real = 41.99;
begin
  writeln( 'The answer is ', foo:0:1 )
end.

Notice how it will automatically round for you. The second number is the precision field, which specifies the number of digits to have after the decimal point. The first number is the width field. You should generally leave it as zero.

Hope this helps.

[EDIT] Oh yeah, you can use variables for the width and precision fields too...

thx! i wasnt using delphi, but it still worked in pascal.

Ah. It works because it is standard Pascal... :)

hi
program to ask the user a username and a password
if pass and username good display OK
else
clear screen and reask the user for username and password again.
this will continue until good username and password entred.
using while loops
thanks in advanced

program to ask the user a username and a password
if pass and username good display OK
else
clear screen and reask the user for username and password again.
this will continue until good username and password entred.
using while loops
thanks in advanced

1. Get your own thread.

2. Post what you've done to try to do the HW assignment. Then we'll help.

var a, b, s:    real;
begin
  write('enter the first number: ');    read(a);
  write('enter the second number: ');    read(b);

  s:=a / b;

  writeln('your answer is: ',s:0:2);
end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.