Board index » delphi » help pascal easy

help pascal easy

help

i need help for a little program

this is a procedure to translate a complex from polar ( e^it) to
cartesian(a+ib)

procedure conversion_polaire_cart;
var hconv:char;
var rconv,tetaconv:real;
         begin
    writeln('  modul  ?');
        readln(rconv);
    writeln(' argument ?');
        readln(tetaconv);
aconv:=rconv*cos(tetaconv);
bconv:=rconv*sin(tetaconv);
writeln('',aconv); writeln('',bconv);
readln(hconv);
end;

it is easy, but i need to do something like :
a1:=aconv;
b1:= bconv;

but it is not working because aconv and bconv are local var

help, thx

 

Re:help pascal easy


David TOLEDANO schrieb:

Quote
> help

> i need help for a little program

> this is a procedure to translate a complex from polar ( e^it) to
> cartesian(a+ib)

> procedure conversion_polaire_cart;
> var hconv:char;
> var rconv,tetaconv:real;
>          begin
>     writeln('  modul  ?');
>         readln(rconv);
>     writeln(' argument ?');
>         readln(tetaconv);
> aconv:=rconv*cos(tetaconv);
> bconv:=rconv*sin(tetaconv);
> writeln('',aconv); writeln('',bconv);
> readln(hconv);
> end;

> it is easy, but i need to do something like :
> a1:=aconv;
> b1:= bconv;

> but it is not working because aconv and bconv are local var

> help, thx

Ah! That's easy too.

procedure conversion_polaire_cart(VAR aconv,bconv:REAL)
var hconv:char;
var rconv,tetaconv:real;
begin
   aconv:=0;
   bconv:=0;

   writeln('  modul  ?');
   readln(rconv);
   writeln(' argument ?');
   readln(tetaconv);
   aconv:=rconv*cos(tetaconv);
   bconv:=rconv*sin(tetaconv);
   readln(hconv);
end;

at the end, you'll have your result in the parameters you give on
calling the procedure:

program test;
var a,b:real;

=> here would your procedure be

begin
   conversion_polaire_cart(a,b);
   writeln(a,' ',b);
end.

Greetings

Markus

Other Threads