Review logic error

Do I have a logic error in 35-47 (48-60)? Or is it in int main?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 14 using namespace std;
 15 
 16 float get_float(string message);
 17 float check_valid_input(float check, float low, float high);
 18 float calc_rect_area(float width, float height);
 19 
 20 int main ()
 21 {
 22    float check, low, high;
 23    float width, height;
 24    string message;
 25 
 26    const float MIN_VALUE = 1;
 27    const float MAX_VALUE = 10;
 28    
 29    float my_input = get_float("Enter a number from 1 to 10 ");
 30    float sample_width = get_float("Enter the width for some imaginary rectangle");
 31    float sample_height = get_float("Enter the height for some imaginary rectangle");
 32    
 33    cout << my_input << endl;
 34    
 35    cout << check_valid_input(my_input, MIN_VALUE, MAX_VALUE) << endl;
 36    
 37    cout << calc_rect_area(sample_width, sample_height) << endl;
 38    
 39    return 0;
 40 }  
 41 
 42 float get_float(string message)
 43 {
 44    float check = atof(message.c_str());
 45    return check; 
 46 }  
 47 
 48 float check_valid_input(float check, float low, float high)
 49 {
 50    float neg = -1.0;
 51    
 52    if(check >= low && check <= high)
 53    {
 54       return check;
 55    }  
 56    else
 57    { 
 58       return neg;
 59    }  
 60 }  
 61 
 62 float calc_rect_area(float width, float height)
 63 {
 64    if (height == 0)
 65       return 0;
 66    else
 67       return width + calc_rect_area(width, --height);
 68 }  
See previous response:
http://www.cplusplus.com/forum/beginner/113992/#msg622885

It would help if you could just post the code, without the extra line numbers.
Topic archived. No new replies allowed.