Return int to double?

Oct 27, 2011 at 4:51pm
Im getting a warning from DEVC++. It is saying "Warning-converting to "int" from "double""

All i want my function to do it return a double instead of an int.

1
2
3
4
5
6
7
8
9
10
11
//find avg
int findavg(int x,int y,int z){
    
    int sum;
    double avg;
    
    sum=x+y+z;
    avg=sum/(double)3;
    
    return avg;
}


How can I get rid of this? Thank you.
Oct 27, 2011 at 4:57pm
Change line 2 so that the return type (the int to the left of the findavg) is a double.

Happy programming!

-Albatross
Oct 27, 2011 at 5:45pm
Thank You!!
Topic archived. No new replies allowed.