I don't see how your code can compile. When the preprocessor is done with it, and it is ready for compiling, it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
// Lots of code from #include <iostream>
int radius = diameter / 2;
int area = radius * radius * 3.14;
using namespace std;
int main()
{
int result;
int diameter;
diameter = 2;
cout << area;
cout << "\n";
return area;
}
|
You are trying to use the variable
diameter before you define what it is, leading to the compilation error:
multiply.h:1: error: 'diameter' was not declared in this scope
Aside from this, you have set
area to be an int. An int cannot represent the value 3.14
If you want a non-integer value of area, you will have to use a non-integer variable.
You never set the value of
diameter anywhere. You cannot expect the code to calculate something based on
diameter when you never set a value.