I'm very new to programming and recently I came across the function topic. As I wanted to experiment out my knowledge I wrote this very basic code
My aim is to make the separate read function, calculate function and print function and to call the three function in the main... However, this code doesn't show any error but the output that it gives is just the garbage value, how can I make it to really work?
#include <stdio.h>
#include <stdlib.h>
void read(int hrs,int pR);
int calc(int hrs, int pR);
void print(int res);
int main()
{
int hours, payRate;
read(hours,payRate);
calc(hours, payRate);
int c = calc;
print(c);
}
void read(int hrs,int pR)
{
printf("enter hours and pay rate");
scanf("%d%d", &hrs, &pR);
}
int calc(int hrs, int pR)
{
int grossPay = hrs * pR;
return grossPay;
}
void print(int res)
{
printf("The grossPay is %d", res );
}