Below shown is a simple C Code. The code which is troubling is in commented area (please remove comment symbol to run those lines, comment symbl is just here to highlight them), here there are two printf's in comment area......... the error is that both are getting executed continuously without letting the user to enter anything...............and when i change location into integer then it works perfectly(changing options "A and B" as "1 and 2")
plz try to help me..................... tnx in advance
#include<stdio.h>
#include<conio.h>
int main()
{
char gender;
char location;
char health;
int age;
printf("enter ur gender F: Female M:Male");
scanf("%c", & gender);
printf("\n Enter ur age");
scanf("%d", & age);
/*
printf("Enter your location E for city F for village ");
scanf("%c",& location);
printf("\n Enter Health C for Excellent D for Poor");
scanf("%c",& health);
*/
if(gender=='M' && health=='C' && location=='A' && (age>=25 &&age<=35))
{
printf("\n Allowed to insure");
printf("\n Premium rate will be 4 per thousand");
printf("\n Max amount can be 2lacs");
}
else if(gender=='F' && health=='C' && location=='A' && (age>=25 &&age<=35))
{
printf("\n Allowed to insure");
printf("\n Premium rate will be 3 per thousand");
printf("\n Max amount can be 1lacs");
}
else if(gender=='M' && health=='D' && location=='B' && (age>=25 &&age<=35))
{
printf("\n Allowed to insure");
printf("\n Premium rate will be 6 per thousand");
printf("\n Max amount can be 10 Thousand");
}
else
{
printf("Not allowed to insure");
}
getch();
}