I am running in to an error which doesn't let me insert all of the required data. I am sure I have my for
loops set up correctly. I'm not exactly sure on what I'm missing but if someone can over look my code, I would highly appreciate it!
I am using Dev C++.
#include <stdio.h>
float loadArray(float *) ;
float calcTotal(float *); // calc total sales
int main()
{
//declare variables
float sales[7];
float weeklyS;
float total;
float totalS;
float highest;
//since these are pointers in the func, u need an &
sales[7] = loadArray(&weeklyS);
total = calcTotal(&totalS); // when calling a pointer use a & to send the address
printf("Total of the week is: %.2f",totalS);
//calcHighest(odom,odom2,milesDrvn,avgMPG);
return 0 ;
}
float loadArray(float *weeklyS)
{
float sales;
int x;
for ( x = 0; x < 7; x++)
{
// have user enter the following
printf("Enter sales for day %d: ",x + 1);
scanf("%d",&*weeklyS);
}
return sales;
}
float calcTotal(float *totalS)
{
float total = 0 ;
int x;
for ( x = 0; x < 7; x++)
{
total += *totalS;
*totalS++;
}
return total; /// return the accumulator
}
ive stated some comments in the code to explain what does what and am not too sure why this code is not running the way it should. I have declared all variables as floats, i believe i have also addressed my pointers correctly and called them properly as well with the * and the &.