0

My program is not working properly help me!!

I want to minus the sum by 1 if the last digit of input =0 but when i run my program it work but if my last digit is 1 out put is same of the output of 0 You can see the code than you can properly understand my question help please!!!! https://code.sololearn.com/cRY7ywQ7D2MJ/?ref=app

2nd Aug 2020, 6:41 PM
Harsh Sharma
Harsh Sharma - avatar
8 Respuestas
+ 1
for( w=0;w<=lens;w++); //you have put semicolon ; remove it.. if(w=lens) // not =, it shloud be ==(comarision) if( input[w-1==0]){ //it is equal to input[0] always true.. cout<<"\nif your binary digit ends with[0] your answer is-->"<<"["<<sum-1<<"]"; } Harsh Sharma read comments above; Corrected code : for( w=0;w<=lens;w++) if(w==lens) if( input[w-1]=='0'){ cout<<"\nif your binary digit ends with[0] your answer is-->"<<"["<<sum-1<<"]"; }
2nd Aug 2020, 6:49 PM
Jayakrishna 🇮🇳
+ 3
you are missing an extra = in line 54
2nd Aug 2020, 6:46 PM
RKK
RKK - avatar
+ 3
if I'm not wrong your line 52 to line 54 are useless.
2nd Aug 2020, 6:54 PM
RKK
RKK - avatar
+ 1
I cant understand what to do now
2nd Aug 2020, 6:46 PM
Harsh Sharma
Harsh Sharma - avatar
0
Can you please solve it
2nd Aug 2020, 6:46 PM
Harsh Sharma
Harsh Sharma - avatar
0
Thank you for your help
2nd Aug 2020, 6:52 PM
Harsh Sharma
Harsh Sharma - avatar
0
Harsh Sharma why later..? There I mean, I put the explanation about the changes in 3 comments.. Read those if want any explanation of changes made... Happy learning, you're welcome...
2nd Aug 2020, 7:00 PM
Jayakrishna 🇮🇳
- 2
Jayakrishna i will do it later
2nd Aug 2020, 6:56 PM
Harsh Sharma
Harsh Sharma - avatar