I dont know how to pass a value from the function total();
to main()
...i want get the value of the prod
and assign its value to bill...But this code i have will only redo the function total()
...Anyone can help please?.
#include <stdio.h>
#include <conio.h>
int header();
int choices(int);
int total(int);
int main()
{
int bill=0,cash;
int choice;
header();
printf("What do you want to buy: ");
scanf("%d",&choice);
choices(choice);
bill=total(cash);
printf("\nTendered amount: ");
scanf("%d",&cash);
printf("\nYour change: %d",cash-bill);
getchar();
getchar();
}
int header()
{
printf("Welcome to my store!\n\n");
printf(" Items available\n\n");
printf("[1] Paper \tP35\n[2] Pen \tP10\n[3] Notebook\tP15\n\n");
}
int choices(int c)
{
int price;
if(c==1)
{
price = 35;
total(price);
}
if(c==2)
{
price = 10;
total(price);
}
if(c==3)
{
price = 15;
total(price);
}
if(c>3)
printf("Error!");
}
int total(int price2)
{
int prod,qnt,t;
printf("\nQuantity: ");
scanf("%d",&qnt);
prod = qnt*price2;
printf("\nBill is: %d",prod);
t=prod;
return t;
}