NO

Author Topic: Why this code is not working ?  (Read 2312 times)

boral

  • Guest
Why this code is not working ?
« on: November 06, 2014, 11:56:53 AM »
Please see the program and point out the mistake. I don't understand why the input is not read in the char qual.

Code: [Select]
#include<stdio.h>

int main()
{
char gen,qual;
int yos;

printf("Enter the gender, year of service and qualification:");
scanf("%c%d%c",&gen,&yos,&qual);

if(gen=='M' && yos>=10 && qual=='P')
printf(" The salary is Rs.15000 ");

else if((gen=='M' && yos>=10 && qual=='G')||(gen=='M' && yos<10 && qual=='P')||(gen=='F' && yos<10 && qual=='P'))
printf("The salary is Rs.10000");

else if(gen=='M' && yos<10 && qual=='G')
printf("The salary is Rs.7000");

else if(gen=='F' && yos<10 && qual=='G')
printf("The salary is Rs.6000");

else if(gen=='F' && yos>=10 && qual=='G')
printf("The salary is Rs.9000");

else if(gen=='F' && yos>=10 && qual=='P')
printf("The salary is Rs.12000");

printf("%c  %d  %c \n\n", gen, yos, qual) ;

}