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
8 Respostas
+ 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<<"]";
}
+ 3
you are missing an extra = in line 54
+ 3
if I'm not wrong your line 52 to line 54 are useless.
+ 1
I cant understand what to do now
0
Can you please solve it
0
Thank you for your help
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...
- 2
Jayakrishna i will do it later