It's really basic. Sorry for posting the whole program, but I have no idea where I've gone wrong.
While executing the bold statement below: If I type 100000 as the policy amount, I get -124 as the output. It should be 400. What have I done?? :-(
Code:
#include<stdio.h>
int main(void)
{
char hlth, resi, sex;
int age,pol_amt;
float prem;
printf("Enter health grade, residence, sex, age:");
scanf( "%c %c %c %d", &hlth, &resi, &sex, &age);
if( hlth=='E' && (age>=25 && age<=35) && resi=='c')
{
printf("\nThe person can be insured.");
if( sex=='M' )
{
printf("\nThe maximum policy amount is 200000");
printf("\nEnter the policy amount:");
scanf("%d", &pol_amt);
prem= (pol_amt/1000)*4;
printf("\nThe premium rate is %f",prem);
}
else if( sex=='F' )
{
printf("\nThe maximum policy amount is 100000");
printf("\nEnter the policy amount:");
scanf("%d", &pol_amt);
prem=(pol_amt/1000)*3;
printf("\nThe premium rate is %f",prem);
}
}
else if( hlth=='P' && (age>=25 && age<=35) && resi=='v' && sex=='M')
{
printf("\nThe person can be insured.");
printf("\nThe maximum policy amount is 10000.");
printf("Enter the policy amount:");
scanf("%d", &pol_amt);
prem=(pol_amt/1000)*6;
printf("\nThe premium rate is %f",prem);
}
else
{
printf("\nThe person is not insured.");
}
getch();
clrscr();
}