Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

How to get your Pascal Code to work on MacOX

A friend wanted me to help with some assignments on Pascal and it really got funny how I couldn't easily install the compiler on MacOx so I decided to put up some blog post for someone who would also like to do same.

You would need Xcode to be installed before FPC is installed. Visit Free Pascal ( and download the installation file. Double click on the .dmg and follow the prompt to install.  It will be installed in /usr/local/bin.

The compiler is called "fpc". Type "fpc" on the terminal and you get a screen like this, then you know your installation was fine.

I wrote a program to calculate the CGPA (Cummulative Grade Point Average) of Students in Pascal. You can find it below for a head start.

	Program CGPA_Calculator;
    units, semesters, i, numerator : integer;
    denominator, cgpa, gpa : real;

    denominator := 0;
    numerator := 0;
    writeln('Welcome to Pascal CGPA Calculator!');
    writeln('How many semester are you calculating for?');
    for i := 1 to semesters do
        writeln('Enter semester ', i, ' GPA');
        writeln('Enter semester ', i, ' Unit');
        denominator :=  denominator + (gpa * units);
        numerator := numerator + units;
    cgpa := denominator / numerator;
    writeln('Your CGPA is ', cgpa:5);

This is just a sample code I decided to play around with. Hope it is helpful.

comments powered by Disqus