• 02-28-2009
XodoX
Hey guys, I want to do the following and I have no idea how to do this. :(

Code:

Function area_regular_hexagon

Pass In: side

Calculate – side times 3 times the square root of 0.75

Pass Out: the calculation

Endfuction

I need to write the C++ code to do the these specific task function. Can someone help me with this?
• 02-28-2009
anon
And what part of it are you having trouble with? What you have to do couldn't be worded more clearly. Post your best effort.
• 02-28-2009
m37h0d
what's not to know? they tell you, practically line by line, what the function is supposed to be.

do you know how to create a function?
• 02-28-2009
XodoX
Honestly, I do't know at all how to do this. It's a problem related to a chapter, but nothing is explained about it in that chapter. Don't really get the pass in/ pass out.
• 02-28-2009
XodoX
Here it goes... that's what I got.

Code:

#include <iostream>
#include <cmath>
using namespace std;

// Function Prototypes
void get_data(void);
void process_data(void);
void show_results(void);
void pause(void);

// Variables

double  side_1;

//******************************************************
// main
//******************************************************

int main(void)
{
get_data();
process_data();
show_results();

return 0;
}

// Input
void get_data(void)
{
cout << "\nEnter the total side_1 in the hexagon --->: ";
cin >> side_1;

return;
}
// Process
void process_data(void)
{
answer = side_1 * 3 * sqrt(0.75);

return;
}

//Output

void show_results(void)
{
cout << "\n";
cout << "\nThe area of the hexagon is---->: ";
pause();
return;
}

//******************************************************
// pause
//******************************************************

void pause(void)
{
cout << "\n\n";
system("PAUSE");
cout << "\n\n";
return;
}

//******************************************************
// End of Program
//******************************************************

But that can't be it. It's supposed to be a short answer.
• 03-01-2009
Salem
It is a short answer. Don't count all the cin/cout fluff.

Oh, and "pass in" and "pass out" means parameters and return values, not global variables.
• 03-01-2009
m37h0d
• 03-01-2009
XodoX
ok thank you guys. Then I will do that.