program mathnote;
uses crt;

{--------------------------------------------------------------------------

program description
                        by 
This program demonstrates order of operations plus how other functions of
Pascal work.

ex. sqr, sqrt, div, mod

--------------------------------------------------------------------------}


VAR result:real ;
    sqrresult:real;
    sqrtresult:real;
    quotient:real;
    remain:real;
    num:integer;
    num2:integer;
begin

clrscr;

{Order of Operations------------------------------------------------------}

textcolor (green) ;

result := 8 + 6 * 4 - 2    ;

writeln ('8 + 6 * 4 - 2     = ',result:0:0) ;
writeln;

result := (8 + 6) * 4 - 2    ;

writeln ('(8 + 6) * 4 - 2   = ',result:0:0) ;
writeln;

result := 8 + 6 * (4 - 2)    ;

writeln ('8 + 6 * (4 - 2)   = ',result:0:0)  ;
writeln;

result := (8 + 6) * (4 - 2) ;

writeln ('(8 + 6) * (4 - 2) = ',result:0:0);
writeln;

result := 8 * 6 / 4 - 2    ;

writeln ('8 * 6 / 4 - 2     = ',result:0:0)    ;
writeln;

result := (8 * 6) / (4 - 2)    ;

writeln ('(8 * 6) / (4 - 2) = ',result:0:0);
writeln;

result := 8 * 6 / (4 - 2)    ;

writeln ('8 * 6 / (4 - 2)   = ',result:0:0);
writeln;

{Functions of Pascal-----------------------------------------------------}

write ('Please enter any real number --->  ')   ;
readln(result);

sqrresult := sqr(result)   ;
sqrtresult := sqrt(result);

writeln;
writeln ('The square of that number is ',sqrresult:1:5)  ;
writeln ('And the square root of it is ',sqrtresult:0:5);
writeln;
writeln;

write ('Please enter another number --->  ');
readln (num);
writeln;

write ('Please enter a number to divide into this number --->  ');
readln (num2)           ;

quotient := num div num2;
remain := num mod num2;

writeln;
writeln;
writeln ('------------------------------------------------------');
writeln;
writeln ('The quotient for these two numbers is ',quotient) ;
writeln;
writeln ('The remainder for these numbers is    ',remain);


readln;

end.