When this program is build and run in Eclipse, it doesn't run as expected: it doesn't ask me to enter a gender and it runs and quits very quickly.
Code:
#include <stdio.h>
int main() {
char edu,gen;
int exi;
float yos;
printf("This program finds out the salary of an employee\nnow if you are graduate then enter g and if you post graduate then enter pg here :- ");
scanf("%c",&edu);
puts("now enter the yers of service of an employee here :- ");
scanf("%f",&yos);
puts("now if you are female then enter f and if you are male then enter m here :- ");
scanf("%c",&gen);
puts("salary of an employee is ");
if(gen=='m' && edu=='pg' && yos>=10)
printf("1500");
else if(gen=='m' && edu=='g' && yos>=10)
puts("1000");
else if(gen=='m' && edu=='pg' && yos<10)
puts("10000");
else if(gen=='m' && edu=='g' && yos<10)
puts("7000");
else if(gen=='f')
{
if(edu=='pg' && yos>=10)
puts("12000");
else if(edu=='g' && yos>=10 )
puts("9000");
else if(yos <10 && edu=='pg')
puts("10000");
else if(edu=='g' && yos <10)
puts("6000");
else
puts("i dont know!!!!! ");
}
puts("\nnow enter any digit to exit\n");
scanf("%d",&exi);
printf("you enterd %d , thus good bye",exi);
return 0;
}
output:
This program finds out the salary of an employee now if you are graduate then enter g and if you post graduate then enter pg here :- g now enter the yers of service of an employee here :- 10 now if you are female then enter f and if you are male then enter m here :-
salary of an employee isnow enter any digit to exit
Is there a way to fix?