Thread: specific task function

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    72

    specific task function

    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?
    I coudln't find anything about this.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    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.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    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?

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    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.
    Last edited by XodoX; 02-28-2009 at 08:20 PM.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    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;
    double  answer;
    
    //******************************************************
    // 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---->: ";
      cout << answer;
    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.
    Last edited by XodoX; 02-28-2009 at 09:13 PM.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    ok thank you guys. Then I will do that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM