954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Total Sales and Sales Tax

Im attempting to write a program that will accept seperate sales amounts from the user and then will total the sales and display both the total sales and the sales tax from the sales at the programs end, if you can provide any help or insight i would greatly appreciate it

#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", a[SIZE] );
 while ( a[SIZE] != -1 ){
       total = sum_array(a,SIZE) ;
       tax = total * .0825;
 printf ("Enter sales (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);
}


many thanks

jeremy62
Newbie Poster
4 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

There are lots of problems in function main(). Since I am responding to your post after 6 hours from when you posted it I hope you did not sit idle all this time watching TV, playing games, or anything else.

I could go on and on about all the problems I see in main() but it would be useless if you have already fixed most, if not all, of them. So please re-post your current program so we can see what progress you have made.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: