Reputation: 161
When I Enter Second Value in Program its Take me to Third Value and not execute properly
when I enter the gender it should ask me to enter degree but take me to enter the third value and program not working properly.
#include <iostream>
#include <stdio.h>
#include <conio.h>
int main()
{
char gender;
char degree;
int age;
printf("Enter Gender (F/M) ");
scanf("%c",&gender);
printf("Enter Degree ");
scanf("%c",°ree);
printf("Enter Age ");
scanf("%d",&age);
if(gender == 'M')
{
if(degree == 'P')
{
if(age >= 35 && age <= 50)
printf("Good Work");
else
printf("Better Luck Next Time");
}
else
{
if(degree == 'G')
{
if(age >= 22 && age <= 40)
printf("Good Work");
else
printf("Next Time");
}
}
}
else
{
if(degree == 'P')
printf("Good Work");
else
printf("Next Time");
}
getch();
}
Upvotes: 0
Views: 53
Reputation: 161
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
int main()
{
char gender;
char degree;
int age;
cout<< "Enter Gender (F/M) ";
cin>>gender;
cout<<"Enter Degree ";
cin>>degree;
cout<<"Enter Age ";
cin>>age;
if(gender == 'M')
{
if(degree == 'P')
{
if(age >= 35 && age <= 50)
printf("Good Work");
else
printf("Better Luck Next Time one");
}
else
{
if(degree == 'G')
{
if(age >= 22 && age <= 40)
printf("Good Work");
else
printf("Next Time two");
}
}
}
else
{
if(degree == 'P')
printf("Good Work");
else
printf("Next Time three");
}
getch();
}
Upvotes: 0
Reputation: 135
Use cin
function instead of scanf
. It will solve your problem.
Upvotes: 1