#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++)
{ 
cin>>x[i];
}
    a=x[0];
    b=x[1];
    c=x[2];
    d=x[3];
    e=x[4];
    cout<<"a="<<a<<endl;
    cout<<"b="<<b<<endl;
    cout<<"c="<<c<<endl;
    cout<<"d="<<d<<endl;
    cout<<"e="<<e<<endl;



}
float calculate_average()
{
        int total=0 ,avg;
        {
        total += float read_input( a,b , c ,d,e );
        avg = total/5 ;
        }
        cout<<avg<<endl;
        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.

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.

commented: thank you soo much you've solved my mess ^_^ +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.