-
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 */
-
-
It might also help if you actually called the functions....
-
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().