I'm new programming i started with c a month ago. I was writing code for my school homework and i was unable verify the gender and salary in the following code that i wrote. Can someone please help me with this.
Following is my question. Q3. A company decides to give bonus to all its employees on New Year. It is decided that 5% bonus will be given to all male employees and 10% bonus will be given to female employees.Further, if the salary of an employee is less than Rs. 10,000, then the employee gets an extra 2% bonus on salary. Write a C program to enter the salary and gender of an employee and calculate the bonus that has to be given to an employee.
following is my code.
int main()
{
char gender[6];
double salary;
double bonusSalary;
printf("enter your gender here:");
scanf("%s", &gender);
printf("enter your salary here:");
scanf("%lf", &salary);
if( gender == 'male' && salary<10000 )
{
bonusSalary=salary*(7.0/100.0);
}
else if( gender == 'male' )
{
bonusSalary=salary*(5.0/100.0);
}
else if( gender == 'female' && salary<10000 )
{
bonusSalary=salary*(10.0/100.0);
}
else if( gender == 'female' )
{
bonusSalary=salary*(12.0/100.0);
}
printf("bonus amount you will receive is:%f", bonusSalary);
return 0;
}
The code i wrote reads gender and salary but whatever you type the bonus is displayed as zero it does not read the if and else if statements.