Make a calculactor with Pascal

In this post,I will tell about how to make a simple calculactor.

Do you know calculactor ? That’s the tools that used to calculate a operation.

What’s the language that will we use ? Okay,we will use the PASCAL langauge.That’s the classic programming language.For the programmer,especially for the participant of computer olympic,would know this language.

Okay,let’s to coding it,kalkulaktor.pas

program calculactor;
uses wincrt; {Using TP for Windows}
var
a,b,c:real; {Definite a,b,c as real}
u,operasi:char; {Definite u,operasi as characters}

label start,finish,restart; {The label will used}
const
line='---------'; {Make the line}
begin

start: {Label start}
clrscr; {Clear the screen}
writeln('Calculactor by Satrio');
writeln(line);
write('Fill first number...');
readln(a); {Read variable a}
write('Fill second number...');
readln(b); {Read variable b}
write('Choose the operation (+/-/:/x)..');
readln(operasi); {Read from operasi}
case operasi of
'+' : c:=a+b;
'-' : c:=a-b;
':' : c:=a/b;
'x' : c:=a*b;
else
writeln('Unknown operation');
writeln(line);
goto start;
end;
writeln(line);
write(a:5:2);
write('',operasi,'');
write(b:5:2);
write('=');
writeln('equal : ',c:5:2);
writeln(line);
restart: {Label restart}
writeln('Wanna to calculate again ? y/n');
readln(u); {Read from variable u}
writeln(line);
case u of
'y' : goto start;
'n' : goto finish;
else
writeln('Input wrong');
writeln(line);
goto restart;
end;

finish: {Label finish}
writeln('Press enter to out');
readln;
end.

2 thoughts on “Make a calculactor with Pascal

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s