Question
Hello i am having trouble with my coding as it is giving me other results for example i set if the input is yes than
Hello i am having trouble with my coding as it is giving me other results for example i set if the input is "yes" than it will print on the true statement. .. but it prints on the other condition.
I hope someone can help me fix this simple c++ code
=============================================
#include
int main() { char name, state; int income, allowance, extra100, citizenship, firstallowance, secondallowance, thirdallowance; allowance = 0; extra100 = 100; firstallowance = 500; secondallowance = 400; thirdallowance = 300;
//name printf("Please enter you username : "); scanf("%s", &name); printf("Welcome %s to our program!", &name);
//citizenship printf(" Are you a malaysian citizen? : "); scanf("%s", &citizenship); if (citizenship == no) { printf(" You are not eligible, This are open for Malaysia citizen only!"); return (0); } else { printf(" You are eligible!"); }
//state printf(" Please enter your state : "); scanf("%s", &state);
if (state = (SABAH) || (SARAWAK)) { printf(" For Sabah and Sarawak state, you will get extra Rm 100 to your allowance "); } else { printf(" No extra RM100 will be given."); }
printf(" Please enter your total family income : "); scanf("%d", &income); if (income > 5000) { printf(" You are not eligible, only family income less then or equal to Rm 5000(MAX) are eligible to participate "); } if (income < 2000) { printf(" You are eligible for allowance. You will get Rm 500 per month ", allowance + firstallowance); } if (income > 2000) { printf(" You are eligible for allowance. You will get Rm 400 per month ", allowance + secondallowance); } if (income > 4000) { printf(" You are eligible for allowance. You will get Rm 300 per month with RM %d ", allowance + thirdallowance, "of allowance"); }
printf("We hope you are happy for the allowance you get, Thank you ");
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started