function definition error

Hi , anyone please help this error In function void computeKilosPerHour (float ,float, float)
error a function definition is not allowed here before '{' token . I cant figure out what is wrong

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
#include <iostream>
#include <iomanip>

using namespace std;

void printDescription ( )
{
cout << "**************************************************************" << endl;
cout << "This program takes two numbers (kilometers and hours)" <<endl;
cout << "and outputs the average speed travelled" << endl;
cout << "**************************************************************" << endl;
}

void computeKilosPerHour (float kilos, float hours, float average)

{

int main ()

{


float kilos, hours, average;
cout << "Welcome to the Travel Calculator" << endl;
printDescription();
cout << "Please input the kilometers travelled" << endl;
cin >> kilos;
cout <<"Please input the hours travelled" << endl;
cin >> hours;
computeKilosPerHour(kilos, hours);

}

average= kilos/hours;
cout << "Your average speed was" << average << "km per hour" << endl;
cout << "We hope you enjoyed this program" << endl ;
return;
}
Indentation might explain:
1
2
3
4
5
6
7
8
void computeKilosPerHour (float kilos, float hours, float average)
{
    int main ()
    {
        // statements
    }
    // statements
}

The compiler does not like about the attempt to define a function inside definition of a function.
ok so how do i rectify it , im sorry still a bit of a dummy in programming
Compiler does not complain about your another function (printD..), does it?
no it doesnt
ok so how do i rectify it

Don't try and define a function inside another function.
mov main, outside_computeKilosPerHour
thank you all
Topic archived. No new replies allowed.