Cannot call properly?

This is a discussion on Cannot call properly? within the C Programming forums, part of the General Programming Boards category; I am working on this basic c program for a class I am taking. We are having trouble getting to ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Cannot call properly?

    I am working on this basic c program for a class I am taking. We are having trouble getting to call the CalculateHourlyWage at the end of the program. We want it to display an employees hourly wage and print it on the screen. I do not have to much experience in C, so any help you guys can provide me with would be great!

    Code:
    /* This is a C program to printout the hourly wage */
    /* given a yearly salary and hours worked per month */
    
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    
    float CalculateMonthlySalary (float, float);
    float CalculateHourlyWage (float, float);
    
    main()
    {
     int YearlySalary;
     int HoursWorkedPerMonth;
     float MonthlySalary;
     float HourlyWage;
     float x, y, z;
     
     /* Define the Yearly Salary */
     YearlySalary=90000;
     
     /* Define the Hours Worked Per Month */
     HoursWorkedPerMonth=160;
     
     x=YearlySalary;
     y=12;  
     z=HoursWorkedPerMonth;  
     
     /* call function product using arguments  */
     printf("** Hourly Wage is $%5.0f ** \n", HourlyWage);
     
    }
    
    /* Two functions are defined as follows */
    
    /* (1) Formula of the calculation of the monthly salary */
     float CalculateMonthlySalary (float x, float y)
    {
     float Salary;
     Salary = (x/y);
      return(Salary);
    }
    
    /* (2) Formula of the calculation of the hourly wage */
     float CalculateHourlyWage (float MonthlySalary, float z)
    {
     float Wage;
     Wage = (MonthlySalary/z);
      return(Wage);
    }
    /* END of the program */

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    It might also help if you actually called the functions....

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    535
    Are you having a specific problem with it? Or do you just not know where to go from here?

    You can print the hourly wage by calling CalculateMonthlySalary() and CalculateHourlyWage() inside the printf. I guess that's what you're trying to work out how to do?

    Start simple -- just call the functions and store the results to the variables you already have. Then you can cram it all into printf later, if you wish.

    Function call would look like this:
    Code:
    MonthlySalary = CalculateMonthlySalary(x, y);
    and similar for CalculateHourlyWage().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Call external C programs and receive data
    By ferenczi in forum C Programming
    Replies: 11
    Last Post: 02-12-2008, 12:32 PM
  2. Multiple types in lists, vectors or arrays.
    By megatron09 in forum C++ Programming
    Replies: 20
    Last Post: 08-31-2006, 02:54 PM
  3. Assembly example
    By Lynux-Penguin in forum C Programming
    Replies: 6
    Last Post: 04-24-2002, 08:45 PM
  4. Help needed with external call, WinExec() and timer.
    By algorithm in forum Windows Programming
    Replies: 9
    Last Post: 11-07-2001, 09:35 AM
  5. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 07:57 AM

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