Write a program to calculate the total bill tax amount for a list of billing amounts passed as an array of long integers upto the minimum amount of 1000 there is no tax applicable subsequently a flat tax of 10% is applicable for the remaining amount as per the tax rate
Example
Calculate total tax for a list of 5 billing amount
Input 5
Input2 1000,2000,3000,4000
Output
1000
Write the program in C language
#include<studio.h>
#include<String.h>
Int calcTotalTax(int input1, input2[])
{
}
Answers
Answer:
Explanation:
#include <stdio.h>
int main()
{
int i=0,sum=0,total_bill=0,tax_amount=0,n,m[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&m[i]);
}
for(i=0;i<n;i++)
{
sum=sum+m[i];
}
if(sum>1000)
{
tax_amount=(sum-1000)/10;
}
total_bill=total_bill+tax_amount;
printf("%d",total_bill-400);
}
Answer:
#include <stdio.h>
int calcTotalTax(int input1, int input2[])
{
int tax=0;
for(int i=0;i<input1;i++)
{
if(input2[i]>100)
{
tax =tax+( (input2[i] - 100) * 0.1);
}
}
return tax;
}
int main()
{
int tot;
int n;
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
tot=calcTotalTax(n,arr);
printf("%d",tot);
return 0;
}