Home>

Please write your question in detail here.

I want to make a program that outputs a value less than the average value of real number data with positive integers.
Even if I think about it myself, it doesn't work.
Specifically, I don't quite understand how to define it and what the configuration will be.

Error message
Severity level Code Description Project file line suppression status
Warning C6031 Return value ignored:'scanf' Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 13
Warning C6031 Return value ignored:'scanf' Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 19
Warning The C6262 function uses the stack '80028' bytes:/analyze: stacksize is greater than '16384'. Consider moving some of your data to the heap. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 3
Warning C6001 You are using uninitialized memory'Num'. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 13
Warning C6031 Return value ignored:'scanf' Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 15
Warning C6031 Return value ignored:'scanf' Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 17
Warning C6270 Missing float argument to'printf': Add the float argument corresponding to conversion specifier '1'. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 28
Error C2057 A constant expression is required. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 7
Error C2466 An attempt was made to allocate or declare an array of size 0. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 7
Error C2133'dnum': Unknown size. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 7
Error C2297'+ =': Invalid. The right operand is of type'double [0]'. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 21
Error C2440'+ =': Unable to convert'double [0]' to'double'. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 21
Error C2143 Syntax error:';' is missing before')'. Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample1.c 29
Warning C4473'printf': Insufficient arguments passed as format string Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 28
Error C4700 Uninitialized local variable'Num' is used Project3 C: \ Users \ nishi \ source \ repos \ Project3 \ Project3 \ Sample2.c 13
Corresponding source code
C language
What I tried

Actually, it's good to write the following program, but I'm not sure about the structure.

include

int main (void)
{
int Num = 0;
double test [10000];
double dnumSum = 0;
double dnumAve = 0;
int i, j;

printf ("Enter the number of data. \ N");
scanf ("% d",&Num);

for (i = 1;i<= Num;i ++) {

printf ("Enter the value of the data.");
scanf ("% lf",&test [i]);

dnumSum + = test [i];

}

dnumAve = (double) dnumSum/Num;

for (j = 1;j<= Num;j ++) {
if (test [j]<= dnumAve) {
printf ("Data below the mean is% f. \ N");

}
}

return 0;
}

Supplementary information (FW/tool version, etc.)

It's good to make it once, but I'm in trouble because I don't know what's wrong.
Please point out. There are some basic things that are missing, so it would be helpful if you could point out those as well.

  • Answer # 1

    I think the source provided is fine.
    Change one place as follows.

    printf ("Data below the mean is% f. \ N");
    To
    printf ("Data below the mean is% f. \ N", test [j]);
    Please change to.

Related articles