Ahmad
Posts: 1
Nickname: lovemoon
Registered: Apr, 2004
|
|
Help Me
|
Posted: Apr 9, 2004 8:45 PM
|
|
Advertisement
|
hello every body
I have a assiment in the borland
Q: a mail order house sells five different products whose retail pricesnare shown in the following table:
2.98 \ 1 4.50 \ 2 9.98 \ 3 4.49 \ 4 6.87 \ 5
write a program that reads a series of pairs of numbers as follow: 1- product number 2- Quantity sold for one day
answer:-
#include <stdio.h> void main () { int items_sold,units_sold,units,sold,units_1,units_2,u nits_3,units_4,units_5;
pri ntf (" enter what items was sold today"); scanf ("%d",&items_sold);
while (items_sold != -1) { printf ("enter how many units of this item was sold"); scanf ("%d",&units_sold);
switch (items_sold){ case 1: units_1 += units_sold; break;
case 2: units_2 += units_sold; break;
case 3: units_3 += units_sold; break;
case 4: units_4 += units_sold; break;
case 5: units_5 += units_sold; break; }
printf (" enter what items was sold today"); scanf ("%d",&items_sold); } }
thank you
|
|