1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <stdio.h>
int main( void )
{
printf("Welcome to\nBIGSALE mall!\n");
int year;
printf("Please enter your year of birth \n");
scanf("%d",&year);
int productcode, quantity_sold;
int productcode1, quantity_sold1, Total1, Product_unit_price1 = 45.20;
int productcode2, quantity_sold2, Total2, Product_unit_price2 = 14.50;
int productcode3, quantity_sold3, Total3, Product_unit_price3 = 3.45;
int productcode4, quantity_sold4, Total4, Product_unit_price4 = 7.80;
printf("Enter product code(enter 1 to 4)(enter -1 to exit) \n");
scanf("%d", &productcode);
while(productcode != -1) //Once started, this loop will never finish. Nothing within the loop modifies the value of productcode.
{
if(productcode == 1)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold1);
}
else if (productcode == 2)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold2);
}
else if (productcode == 3)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold3);
}
else if (productcode == 4)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold4);
}
else
{
printf("The code does not exist. Please try again!");
}
}
//printf("Enter quantity sold \n");
//scanf("%d", &Quantity_Sold);
return 0;
}
|