- 1

My this code is not working. Please help me

#include <stdio.h> int main() { int salary,allow; float hra,da,pf,total; int grade; printf("Hello Everyone, This is a program to find the salary"); printf("\n Please Enter Your Basic Salary"); scanf("%d",&salary); printf("Please enter your grade"); scanf("%d",&grade); hra=0.2*salary; da=0.5*salary; pf=0.11*salary; printf("Your HRA is %f",hra); printf("Your DA is %f",da); printf("Your PF is %f",pf); if(grade==1){ allow=1700; printf("Your allow amount is %d",allow); } else if(grade==2){ allow=1500; printf("Your allow amount is %d",allow); } else{ allow=1300; printf("Your allow amount is %d",allow); } total=salary+hra+da+allow-pf; printf("Your total salary is %f",total); }

16th Aug 2019, 4:41 AM
Aryan Grover
Aryan Grover - avatar
4 Answers
+ 4
Aryan Grover what issue you are facing? I checked for 500 and 1 and it worked.... please note that sololearn application takes all input in one go... so your all input should be in one entry either seperated by space or new line
16th Aug 2019, 5:22 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 4
Aryan Grover Your question is OK, I just came to remind you that you have written a C code but you put C++ and Java in Relevant Tags. I would respect it if you can adjust it so it fits in the question well : ) P.S. You have accidentally created 2 copies of this thread, kindly remove one to reduce duplicate questions. Thanks for understanding 👍 https://www.sololearn.com/Discuss/333866/?ref=app https://www.sololearn.com/Discuss/1932616/?ref=app
16th Aug 2019, 6:40 AM
Ipang
+ 1
It's not working. It always takes allow amount as 1300 whether I put grade as A or even C. Please tell me regarding that
16th Aug 2019, 1:14 PM
Aryan Grover
Aryan Grover - avatar
+ 1
Aryan Grover it must take 1300 for any grade as your grade comparison is for 1,2 not a, b... your input grade is int...so change it to char and do compare as below : char grade; scanf("%d",&grade); if(grade == 'A' || grade== 'a')
16th Aug 2019, 2:17 PM
Ketan Lalcheta
Ketan Lalcheta - avatar