You are on page 1of 2

#include <stdio.

h>
int displayMenu();
float price();
void output();
float cost[10], sell[10], total = 0, profit = 0; int i=0;
void main(void)
{

int num;
printf("====================\n\tMENU\n====================\n\t1.Read
Information of buying cost and selling price\n\t2.Print output\n\t3.Exit\nEnter yor
choice<1-3>:");
scanf_s("%d", &num);
switch (num)
{
case 1:price(); break;
case 2: output(); break;
case 3:printf("\n=====BYE=====\n"); break;
default: displayMenu(); break;
}

float price(void)
{

for (i = 0; i < 10; ++i) {


printf("Enter cost price %d:", i + 1);
scanf_s("%f", &cost[i]);
printf("Enter sell price %d:", i + 1);
scanf_s("%f", &sell[i]);

}
return displayMenu();
}
void output()
{
for (i = 0; i < 10; ++i) {
profit = sell[i] - cost[i];
total += profit;
}
printf("Profit= %.2f\n", total);
displayMenu();
}
int displayMenu()
{
int num;
printf("====================\n\tMENU\n====================\n\t1.Read
Information of buying cost and selling price\n\t2.Print output\n\t3.Exit\nEnter yor
choice:");
scanf_s("%d", &num);
switch (num)
{
case 1: price(); break;
case 2: output(); break;
case 3:printf("\n=====BYE=====\n"); break;
default: displayMenu(); break;
}
return 0;
}

You might also like