Compiling Pascal Program in Linux

This item was filled under [ Pascal Tricks ]

It’s interesting to use another operating system besides Windows, like Linux. We also can write and compile a Pascal code in various Linux distro. One of the example is Ubuntu, i’m using this distro because it’s easy to use. For Ubuntu, I’m using Geany IDE to compile any Pascal Program.

Geany is a text editor using the GTK2 toolkit with basic features of an integrated development environment. It was developed to provide a small and fast IDE, which has only a few dependencies from other packages. It supports many filetypes and has some nice features.

We can download Geany from this link
Geany Download

or by typing this command in terminal
apt-get install geany.

For another distro, we can see the Geany Releases Notes, here.

Pascal Binary Search Algorithms

This item was filled under [ Uncategorized ]

When we try to search something inside the big number of data, we can try this algorithms that divide the data into two divisions, so that the area of searching will become limited.
Continue reading…

Check All Letters in A Sentence Using Pascal

This item was filled under [ Pascal Life, Pascal Problem's Answers, Pascal Tricks ]

A sentence is consist of several letters. Like this example, Hello World. This sentence consist of:

  • 2 ‘o’ lowercases
  • 1 ‘e’ lowercase
  • 3 ‘l’ lowercases
  • 1 ‘d’ lowercase
  • 1 ‘r’ lowercase
  • Continue reading…

Basic Mathematica Operations in Fractions Number

This item was filled under [ Pascal Life, Pascal Problem's Answers, Pascal Tricks ]

If you want to adding, multiply, division, or reduct two fractions number, you can use this simple algorithms made by me. :) Its using a function so, the main program is merely simple.

program pecahan_son;
uses crt;
var sebut1,sebut2,bilang1,bilang2:integer;
hsebut,hbilang:integer;
menu:string;
Continue reading…

Algorithms fo Finding The Value of X from A Quadratic Equation

This item was filled under [ Pascal Life, Pascal Problem's Answers, Pascal Tricks ]

There is an algorithms for finding a solution from a quadratic equation. Well, for example if we have some quadratic equation like x^2+7x+12 then we can find the value of x is -4 and -3 from (x+4)(x+3). If you want the simple methods of that problem, we can write a program in pascal with this algorithm.

program akar_kuadrat;
uses crt;
var
a,b,c:real;
procedure hitung(a,b,c:real);
var x1,x2:real;
begin
if b*b-(4*a*c) < 0 then
begin
writeln('Akar imajiner');
end
else
begin
x1:=(-b+sqr(b*b-4*a*c))/(2*a);
x2:=(-b-sqr(b*b-4*a*c))/(2*a);
write('akar akar dari ',a:0:0,'x^2+',b:0:0,'x+',c:0:0,'adalah ',x1:2:1,' dan ',x2:2:1);
end
end;
begin
clrscr;
writeln('==========mencari akar persamaan dari ax^2+bx+c===========');
writeln;
writeln('masukkan nilai a');readln(a);
writeln('masukkan nilai b');readln(b);
writeln('masukkan nilai c');readln(c);
hitung(a,b,c);
readln;
end.

This program uses a procedure to find the value of x and the determinant, so when the value of determinant (D) is less than 0, that’s mean the value of x is imaginer and cannot be calculated.