Reputation: 21
This function i have returns the billType
and I want to use this billType
in my main function.
int bill()
{
int billType;
printf("Enter bill type (1=utilities, 2=internet) : ");
scanf("%d",&billType);
return billType;
}
here main function:
int main()
{
int discount;
bill();
if(billType == 1)
{
int choice;
printf("\nEnter 1=TNB or 2=SYABAS: ");
scanf("%d", &choice);
if(choice == 1)
{
discount= 0.05;
}
else if(choice == 2)
{
discount= 0.10;
}
}
if(billType == 2)
{
int choice;
printf("\nEnter 1=DIGI, 2=UNIFI or 3=MAXIS FIBRE : ");
scanf("%d", &choice);
discount = 0.05;
}
}
Upvotes: 0
Views: 34
Reputation: 75062
You will want to assign the return value to a variable for later use.
You should change
bill();
to
int billType = bill();
Also it looks weird to assign small values such as 0.10
and 0.05
to int discount;
because they will be truncated to zero. Consider using another type (for example, double
) or remove the meaningless lines (because discount
is not read).
Upvotes: 1