#include <iostream>
using namespace std;

float read_input()

float x[5],a, b ,c, d ,e ;
cout<<"enter 5 numbers:"<<endl;
for (int i=0; i<5; i++)

float calculate_average()
        int total=0 ,avg;
        total += float read_input( a,b , c ,d,e );
        avg = total/5 ;
        return 0;

this is my code but i keep getting (error C2062: type 'float' unexpected)
i real dont know what to do :((((

total += float read_input( a,b , c ,d,e );
Why does this line of code contain the word float?

Also, inside the funciton calculate_average, the following variables do not exist; a, b, c, d, e. So you cannot use them in this function call. That's OK, though, because the function read_input doesn't actually accept any parameters.

Also, your function read_input says it returns a float, but it doesn't return anything.

You have no main function. Maybe your main function is in another source file, but if you were at the level of being able to use more than one source file, you wouldn't be making these mistakes, so I bet you don't have a main function.

Edited 1 Year Ago by Moschops

total += float read_input( a,b , c ,d,e );

The syntax is wrong for this line. First, the float keyword is unnecessary (perhaps you meant it to be a cast?). Second, read_input does not accept any parameters, so the arguments are also not needed. Try this instead:

total += (int)read_input();

Finally, read_input is defined to return a value, but doesn't actually return a value.

On a side note, consistent formatting would make your code easier to read.

thank you soo much you've solved my mess ^_^
This article has been dead for over six months. Start a new discussion instead.