Ok, so I got a program to do in TurboPascal but it's not doing the one of the requirements and I'm not sure how to get it so the question states: Write a program to read in the names of a sequence of products and their price. The program terminates when a 0 price is encountered for a product. The program should print the number of items purchased and a grand total. The data will be entered in the following order: Product,Price,Product,Price...

This is what I have so far:

program sequence;

uses wincrt;

var price,count,pre_sum,new_sum,sum,new_price:integer;product:string;


 While price<>0 do
      Writeln('Grand Total: ',sum);
      Writeln('The number of items purchased is ',count);


It's suppose to add all the prices together, but once i go more than 2 prices for 2 products, it gives me incorrect numbers, im trying to get a grand total each time a product is entered for eg. Ham-500,Chicen-500 Grand Total=1000 or Ham-500,Chicken,200,Rice-300...Grand Total=1000 but it just wont add the third price with the previously entered prices

I should init sum to zero before the while and line 16 should read sum := sum + Price;
EDIT: ho, count should also be initialised to zero.

Your idea worked!!! Just that it needed a bit of adjusting :D(initializing sum:=Price;before while) thanks much man thanks!!! If you have the time could you check out my other post? Title is "This doesn't make sense"... Thanks again.