Help me debug this one... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Help me debug this one...

#include <stdio.h> #include <stdlib.h> int main() { int gross; int net; int taxam; printf("PLEASE INPUT THE GROSS PAY"); scanf("%d" ,& gross); if (gross<20000) { printf("NET PAY = ",gross); printf("TAX AMOUNT =0"); } else if(20000<=gross<30000) { printf("YOUR NET PAY IS:",gross*0.90); printf("YOUR GROSS TAX IS:" gross* 0.10); } else if(30000<=gross<40000) { printf("YOUR NET PAY IS: " ,gross*0.85); printf("YOUR TAX AMOUNT IS:",gross*0.15); } else if(40000<=gross<50000) { printf("YOUR NET PAY IS: " ,gross*0.80); printf("YOUR TAX AMOUNT IS:",gross*0.20); } else { printf("YOUR NET PAY IS: " ,gross*0.70); printf("YOUR TAX AMOUNT IS:",gross*0.30); } return 0; }

23rd Feb 2019, 11:22 AM
Augustine
Augustine - avatar
10 Answers
+ 2
There are way to many places you made mistakes at...You didn't place any format specifiers in your printf's plus your if and else statements are badly written..
23rd Feb 2019, 11:28 AM
Mensch
Mensch - avatar
+ 2
You just need to learn more about C then you'll understand it better...good luck.
23rd Feb 2019, 11:38 AM
Mensch
Mensch - avatar
+ 2
Kodak You have incorrectly created the conditions for calculating the tax.
23rd Feb 2019, 1:33 PM
Solo
Solo - avatar
23rd Feb 2019, 11:37 AM
Mensch
Mensch - avatar
+ 1
https://code.sololearn.com/cghrfSlBuA5A/?ref=app
23rd Feb 2019, 1:20 PM
Solo
Solo - avatar
+ 1
Vasiliy what do you mean???
23rd Feb 2019, 1:39 PM
Mensch
Mensch - avatar
+ 1
Kodak else if(20000<=gross||gross<30000) // || stands for or, but you must "and" - "&&"☺
23rd Feb 2019, 1:46 PM
Solo
Solo - avatar
0
Kodak...please explain
23rd Feb 2019, 11:29 AM
Augustine
Augustine - avatar
23rd Feb 2019, 11:30 AM
Augustine
Augustine - avatar
0
Thanks kodak...that really helps
23rd Feb 2019, 12:24 PM
Augustine
Augustine - avatar