• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Tuesday, August 21, 2012

PASCAL - SAMPLE PROGRAM RECORD

Hello user… welcome to my site in “We Are Knowledge”…

Previous I was giving you IT Knowledge about “C++” and discucc of “RECORD”..

And now I want giving example program using RECORD…

You can copy this codingand paste in your aplication or paste in your “notepad”.

Example 1:

uses crt;
type product = RECORD
name_product : string[20];
sum_product : byte;
price_product : real;
total : real;
end;
var sell : array [1..10] of product;
i, j, x    : integer;
tot1     : real;
Begin
clrscr;
write ('How Many You Will Input Product : '); readln (x);
clrscr;
I := 1;
Write ('Product Name        : '); readln (sell[i].name_product);
Repeat
Write ('The Amount Of Goods : '); readln (sell[i].sum_product);
Write ('Price Of Goods      : '); readln (sell[i].price_product);
sell[i].total := sell[i].sum_product * sell[i].price_product;
inc (I);
write('Product Name        : '); readln (sell[i].name_product);
until (I = x + 1);
dec(i);
clrscr;
writeln ('------------------------------------------------------------');
writeln ('No  Product Name       quantity     Price         Total');
writeln ('------------------------------------------------------------');
for j := 1 to I do
begin
gotoxy (1, j + 3);  write (j);
gotoxy (5, j + 3);  write (sell[i].name_product);
gotoxy (17, j + 3); write (sell[i].sum_product : 10);
gotoxy (30, j + 3); write (sell[i].price_product : 10 : 2);
gotoxy (46, j + 3); write (sell[i].total : 10 :2 );
tot1 := tot1 + sell[j].total ;
end;
writeln;
writeln ('------------------------------------------------------------');
writeln ('Total :                                      ',tot1 : 10 : 2);
writeln ('------------------------------------------------------------');
readln;
end.


Note :

If last you using copy and paste, please for change all quotes (“ “) or (‘ ‘)
If  you paste in your notepad, please save with save as type = “pas”. Example = ”record.pas”.


To result :

Before you input the product you must input “how many product you will input”…

If you input number = “3” then you want input three items.
If you input number = “5” then you want input five items. And so on



Ok.. just it…
I hope you good luck…
See you later

No comments:

Post a Comment