In this article I would like to share with you a sample program that will ask the user to give two numbers and then our program will compute the sum and product of the two given numbers using Turbo Pascal for Windows as our compiler. The code uses function to return the computed value. I hope you will find my work useful. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Program Square_Number;
Uses WinCrt;
var val_1,val_2, add,multiply : integer;
Function sum(a,b : integer) : integer;
Begin
sum := (a+b);
End;
Function product(a,b : integer) : integer;
Begin
product := (a*b);
End;
Begin
clrscr;
writeln('SUM AND PRODUCT OF TWO NUMBERS IN PASCAL');
writeln;
Write('Enter First Number : ');
Readln(val_1);
Write('Enter Second Number : ');
Readln(val_2);
add := sum(val_1,val_2);
multiply := product(val_1,val_2);
writeln;
write('The sum of ',val_1, ' and ' ,val_2, ' is ' ,add,'.');
writeln;
write('The product of ',val_1, ' and ' ,val_2, ' is ' ,multiply,'.');
writeln;
writeln;
writeln(' END OF PROGRAM ');
readln;
End.