Here I have two functions and I call Both of them in my MAIN function. The first function gives me a value of "wage" and I want to use the value of "wage" in my 2nd function. But this doesn't work. Also, I will be using my variable in another function later in my code. Is there any way to call my values efficiently?
Here is the main function call:
#include <stdio.h>
#include <string.h>
int main()
{
categoryA();
workingInfo();
}
1st function that has value of "wage" :
void categoryA()
{
printf("\n\nCategory A: Administrative Worker[1]\n\t Data Entry Operator[2]\n\t Data Entry Clerk[3]\n\t Betting Clerk[4]\n");
int position;
float wage;
float overWage;
char positionName[100];
printf("Choose Your Job Title : ");
scanf("%d",&position);
if(position == 1)
{
wage = 12.5;
overWage= wage*1.15;
strcpy(positionName, "Administrative Worker");
}
else if (position == 2)
{
wage = 13;
overWage= wage*1.15;
strcpy(positionName,"Data Entry Operator");
}
else if (position == 3)
{
wage = 13.2;
overWage= wage*1.15;
strcpy(positionName, "Data Entry Clerk");
}
else
{
wage = 13.5;
overWage= wage*1.15;
strcpy(positionName,"Betting Clerk");
}
printf("wage in the category function : %.2f\n",wage);
}
2nd function where I want to use "wage" :
void workingInfo(float wage)
{
printf("wage in the working info %.2f\n",wage);
}