I'm trying to write a program that will accept input from the user as sales, then it will total the sales and display both the total and the sales tax (total multiplied by .0825
#include <stdio.h>
#include <stdlib.h>
#define SIZE 9
int main(void)
{
/*initialize */
int a[SIZE]= {0};
int total, sales, tax;
/*input data */
printf ( "Enter sales (enter -1 to end):$ ");
scanf ("%d", &sales );
while ( sales != -1 ){
total = sum_array(a,SIZE) ;
tax = total * .0825;
printf ("Enter sales in a week(enter -1 to end):$ ");
scanf ( "%d", &sales );
}
printf("total = %d\n", sales);
printf("sales tax= %d\n", total);
system("PAUSE");
}
int sum_array(int a[], int num_elements)
{
int i, sum=0;
for (i=0; i<num_elements; i++)
{
sum = sum + a[i];
}
return(sum);
}
output
Enter sales (enter -1 to end):$ 100
Enter sales in a week(enter -1 to end):$ 200
Enter sales in a week(enter -1 to end):$ 200
Enter sales in a week(enter -1 to end):$ -1
total = -1
sales tax= 0
Press any key to continue . . .