Why is the output of my results 0.0000?

时间:2018-05-06 17:07:19

标签: c

Hey people this is my first question on this page. I have been learning C in university and I have to complete an activity where I insert name, surname and 4 grades, of 3 different students. After that I must calculate average grade, maximum and minimum grade, and print those results on screen.

The program compiles correctly without errors, but when the results are printed, the program says that average grade, maximum and minimum grade are all equal to 0.000000.

I really don't know what the problem is and I would apreciate if anyone could check it out and help me in any way.

(Sorry if you don't understand the variable names, I'm from Argentina and they are in Spanish)

url="https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&type=parking&key=[YOUR KEY HERE]"

1 个答案:

答案 0 :(得分:1)

我认为您使用的功能并未进行任何更改

float promedio (struct alumno a, struct notas b)  

您发送给该函数的所有参数都需要是地址类型 像这样

void promedio (struct alumno *a, struct notas *b) 
.
.
.
promedio (&alumno3, &notas3);

关于按价值呼叫的问题&通过引用致电

另一个问题是你总是在每个函数中返回0 为什么不使用' void'或返回计算结果,结果必须由参数

接受
float notamaxima (struct alumno a, struct notas b)
{
    if ((a.nota1>a.nota2) && (a.nota1>a.nota3) && (a.nota4>a.nota4))
    {
        return a.nota1;
    }...
}

b.nmax = notamaxima (alumno1, notas1);

你的教授不可能知道这一点。

sry for my eng