Showing posts with label Addition of Two Numbers in Pascal. Show all posts
Showing posts with label Addition of Two Numbers in Pascal. Show all posts

Friday, March 17, 2017

Sum and Product of Two Numbers in Turbo Pascal

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.




Saturday, July 30, 2016

Addition of Two Numbers in Turbo Pascal

Here is a simple program that I wrote maybe 16 years ago in Pascal using Turbo Pascal 5.0 for DOS as my Pascal compiler. The program will ask the user to give to integer number and then it will compute the sum of the two numbers. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Program Listing

Program Addition_Two_Numbers;
Uses Crt;

Var A,B  : Integer;
    Ch   : Char;

Function Add(Var C,D : Integer) : integer;
Begin
 Add := C + D;
End;

Begin
 Repeat
 Clrscr;
 Write('Enter the First Value :');
 Readln(A);
 Write('Enter the First Value :');
 Readln(B);
 Writeln;
 Write('The sum of two values is',' ',Add(A,B));
 Writeln;
 Writeln;
 Repeat
 Write('Do You Want To Continue y/n ? ');
 Ch := Upcase(Readkey);
 Until Ch in ['Y','N'];
 Clrscr;
 Until Ch = 'N';
 Exit;
 Readln;
End.