pLz. help in solivng a C question...
*img195.imageshack.us/img195/5661/salary.jpg
actually i am stuck at one question
after running it it tells always SALARY=0.
i amnot able to find out error so help me in finding error.
question is in attached URL with questi0n and solution which is given in the book "let us c"
and i tried to do it in the way which my computer teacher taught me earlier
here's my coding:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char g,pg,ug;
int yos,q,s=0;
printf("\n Enter the gender , year of service ,qualification:");
scanf(" %c %d %d ",&g,&yos,&q);
if(g=='m' && yos>=10 && q==pg)
s=15000;
else if((g=='m' && yos>=10 && q==ug)||(g=='m' && yos<10 && q==pg))
s=10000;
else if(g=='m' && yos<10 && q==ug)
s=7000;
else if(g=='f' && yos>=10 && q==pg)
s=12000;
else if(g=='f' && yos>=10 && q==ug)
s=9000;
else if(g=='f' && yos<10 && q==pg)
s=10000;
else if(g=='f' && yos<10 && q==ug)
s=6000;
printf("\n salary of employee=%d\n",s);
getch();
}
and btw i also tried da method given in book and still it does not tell the salaray....
here's book method :
#include<stdio.h>
int main()
{
char g;
int yos,qual,sal=0;
printf("Enter gender ,year of service and qualifications(0=g,1=pg):");
scanf("%c%d%d",&g,&yos,&qual);
if(g=='m' && yos>=10 && qual==1)
sal=15000;
else if((g=='m' && yos>=10 && qual==0)||(g=='m' && yos<10 && qual==1))
sal=10000;
else if(g=='m' && yos<10 && qual==0)
sal=7000;
else if(g=='f' && yos>=10 && qual==1)
sal=12000;
else if(g=='f' && yos>=10 && qual==0)
sal=9000;
else if(g=='f' && yos<10 && qual==1)
sal=10000;
else if(g=='f' && yos<10 && qual==0)
sal=6000;
printf("\n salary of employee=%d\n",sal);
return 0;
thx in advance