I'm a beginner and don't know how to use modules. So I have a task :
Code:
Write a main() program that prints a monthly sales report. This report will list the sales for each store the company owns and the total sales. To do this it must first call a module / function that takes in the sales for each store. The sales should be stored in an array of the appropriate data type (assume the dollar value of sales can be really big). Since there are only 3 stores, the array only needs to store 3 values. This array is initialised in main(), and any data entered in other module(s) must be stored in that array. This CANNOT be done using global scope, you must pass the array to the module(s).
What I wrote :
Code:
#include <stdio.h>
main()
{
float balance[3];/* the array*/
int i;
for (i = 0; i < 3;)
{
i = i + 1;
printf("Enter sales amount for store #%d\n",i);
scanf("%f",&balance[i-1]);
}
printf("MONTHY SALES REPORT (BY STORE NUMBER):\n");
printf("Store #1 $ %f\n",balance[0] );
printf("Store #2 $ %f\n",balance[1] );
printf("Store #3 $ %f\n",balance[2] );
}
What I've tried to do
Code:
#include <stdio.h>
int ILikeCats(float balance[3])
{
for (i = 0; i < 3;)
{
i = i + 1;
printf("Enter sales amount for store #%d\n",i);
scanf("%f",&balance[i-1]);
}
}
main()
{
float balance[3];/* the array*/
ILikeCats(float balance[3]);
printf("MONTHY SALES REPORT (BY STORE NUMBER):\n");
printf("Store #1 $ %f\n",balance[0] );
printf("Store #2 $ %f\n",balance[1] );
printf("Store #3 $ %f\n",balance[2] );
}
Could you help and explain it? Thanks in advance!