-
help for c++
#define currentSalary 2500
#include <stdio.h>
#include <math.h>
int main()
{
char status,f,p;
int serviceYears;
float newSalary;
printf("Enter employee status:");
scanf("%c", &status);
printf("Enter year of service:");
scanf("%d", &serviceYears);
if(status = 'f')
{
if( serviceYears < 5 )
newSalary = (currentSalary * 0.04) + currentSalary;
else
newSalary = (currentSalary * 0.05) + currentSalary;
}
else
if(status = 'p')
{
if( serviceYears < 5 )
newSalary = currentSalary + (currentSalary * 0.02);
else
newSalary = currentSalary + (currentSalary * 0.03);
}
printf("Your new salary is RM %0.2f\n", newSalary);
system("pause");
return 0;
}
why can't i get diff ans when input status p?
-
well you should use == not = in your if statements, and use the code tags to show your examples properly
-
thx. n what is code tags?? sorry 4 asking coz i'm new to this forum.
-
-