Function Program

This is a discussion on Function Program within the C++ Programming forums, part of the General Programming Boards category; Can someone please help, I have this program that is due tomorrow Here is the problem: Write a program that ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    3

    Function Program

    Can someone please help, I have this program that is due tomorrow
    Here is the problem:

    Write a program that calculates the average number of days a company's employees are absent. The program should have the following function:

    - a function called by main that asks the user for the number of employees in the company. this value should be returned as an int. ( the functions accepts no arguments)

    - A function called by main int accepts one argument . the number of employees in the company. the function should ask user to enter the number of days each empolyee missed during the yr.the total of these days should be return as an int.
    - a function called main that takes 2 arguments the number of employees in the company and the total number of days absent for all employees during the yr. the function should return as a double, the avrage number of days absent. (input invalidation : don't accept a number less than 1 for the number of employees. dont accept a negative number for the days any employees missed)



    thanks I really need help

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,268
    What have you tried?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    3
    we are using c++ ... here is wat i came up wit
    Code:
    #include <iostream>
    using namespace std;
    
     void displayvalue (int)
    int _tmain()
    {
    	int num1,
    		num2; //  holds the value of number
    		
    		
    
    	cout << "Enter number of employees in the company:\n";
    			cin >> num1;
    		cout <<"Enter number of employees missed:\n";
    			cin >> num2;
    	return 0;
    }

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    3
    can u help me start this program

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    68
    Well first thing you will need before your main function is there function prototypes and after your main function you need to define those depending on what they need to do.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,268
    Well, consider this:
    - a function called by main that asks the user for the number of employees in the company. this value should be returned as an int. ( the functions accepts no arguments)
    Try to write this function. You pretty much have the right idea for this part, except that you are not putting it into another function.

    You should use a loop for this:
    - A function called by main int accepts one argument . the number of employees in the company. the function should ask user to enter the number of days each empolyee missed during the yr.the total of these days should be return as an int.
    Are you sure that you copied this correctly?
    - a function called main that takes 2 arguments the number of employees in the company and the total number of days absent for all employees during the yr. the function should return as a double, the avrage number of days absent.
    Those requirements are incorrect since it is forbidden to overload the global main function. However, we can infer that the "2 arguments" do not describe the arguments to the function, but to the reading of input from the user and computation of the total number of days absent. Furthermore, the "return as a double" should actually be "print as a double".

    Also, try to make your indentation consistent. Use descriptive variable names.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Sep 2009
    Posts
    68
    Quote Originally Posted by cutie0507 View Post
    - a function called main that takes 2 arguments the number of employees in the company and the total number of days absent for all employees during the yr. the function should return as a double, the avrage number of days absent. (input invalidation : don't accept a number less than 1 for the number of employees. dont accept a negative number for the days any employees missed)
    I am going to assume that you meant a function called by main here too?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Replies: 2
    Last Post: 05-10-2002, 05:16 PM
  4. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 11:00 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 10:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21