could anyone help I just started learning c and I couldn't fix this this error in the program
errors are
stat.c:16: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
stat.c:25: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
line 16 void pop_arr(double data[], const int sz)
line 25 void print_arr(const double data[], const int sz)
the code
errors are
stat.c:16: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
stat.c:25: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant
line 16 void pop_arr(double data[], const int sz)
line 25 void print_arr(const double data[], const int sz)
the code
Code:
#include <stdio.h>
#define sz 10
double read_double(const char* prompt)
{
double result;
printf("%s", prompt);
while(scanf(" %lf", &result) != 1)
{
scanf("%*[\n]");
printf("%s\n", prompt);
}
return result;
}
void print_arr(const double data[], const int sz)
{
int i;
for (i = 0; i < sz; i++)
{
printf("%lf\n", data[]);
}
}
void pop_arr(double data[], const int sz)
{
int i;
for (i = 0; i < sz; i++)
{
data[i] = read_double("Enter a value");
}
}
int main()
{
double data[sz];
pop_arr(data, sz);
print_arr(data, sz);
// return 0;
}
Comment