1 line error code (average formula), please check. URGENT

can someone check my code and see how can i fix the error on the formula?

The error comes in this line:

I have to calculate the average for 3 califications.

p.s. I am using DevC++
#include <stdio.h>

struct student
		char nombre[50];    // name of the student
		int anio[4];         // year
		float nota1[3];	    // first calification
		float nota2[3];	    // second calification
		float nota3[3];	    // third calification
		float promedio[8];  // THIS IS THE AVERAGE
		char estado[1];     // APPROVED OR REJECTED?

int main(void)
	          struct student d[30];
	          int cont;
              float average;

	           for(cont = 0; cont < 30; cont++)
		                 printf("Name: ", &cont);
                         scanf("%s", d[cont].nombre);
                         printf("Ingrese Año Lectivo: ");
		                 scanf("%s", &d[cont].anio);
		                 printf("Ingrese Primera Nota del Certamen: ");		       
		                 scanf("%d", &d[cont].nota1);
		                 printf("Ingrese Segunda Nota del Certamen: ");		       
		                 scanf("%d", &d[cont].nota2);
		                 printf("Ingrese Tercera Nota del Certamen: ");		       
		                 scanf("%d", &d[cont].nota3);             
                         printf("The average is;,%.2f",average);

Open in new window

José PerezAsked:
Who is Participating?
declaring nota1 a float instead of an array was one of the suggestions
parentheses are unbalanced.
there are three  left ( and four right )
José PerezAuthor Commented:
for some reason it did not paste the first one, any way, it does no change, the error is the following:

invalid operands of types `float[3]' and `float[3]' to binary `operator+'
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

d[cont].nota1 and d[cont].nota2 are arrays of three floats
+ does not work on arrays.
Did you want to select a particular element of the array?
José PerezAuthor Commented:
The current element of the array, defined by "cont"

what would you suggest?
d[cont] selects an element of the d array.
to get a float, you need to select an element of the nota1 array

I don't think you want to use cont to select from the nota1 array, since the nota1 array has only 3 elements,
and the value of cont can be greater than 2

But it's not clear why you'd want to declare nota1 as an array of floats, instead of as a float anyway.
José PerezAuthor Commented:
Honestly I dont know how to do it, I just tried to do this way but it does not work. If you see i just want to calculate the average of nota1+nota2+nota3.

can you propose some way to fix this program?
José PerezAuthor Commented:
I fix it!!!!!

the solution is doing this:

            float nota1;
            float nota2;
            float nota3;
José PerezAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for oscargarin's comment http:/Q_27409811.html#37009925

for the following reason:

I found the answer by my self.
Hugh McCurdyCommented:
Note to moderator: I agree with Ozo.  While the author did solve the problem, he/she did so after Ozo posted sound assistance that was used in the solution.
José PerezAuthor Commented:
ok. what is suggested in case an answer was part of the solution?
José PerezAuthor Commented:
will it be fair to award 100 point each?
Hugh McCurdyCommented:
It's not uncommon for an author to be involved in solving the problem.  IMH(unofficial)O the helper(s), in this case Ozo, should still credited for their effort.

If I asked the question, I would have awarded all the points.  (You can't actually award points to yourself anyway.)  But you should do what you feel is fair.

Whatever you do, don't give me any points.  I didn't help solve the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.