+ 6

Can someone help me fix this code?

My problem is: How to get the result from the conversion Supposedly the result will be checked in if((n&(n>>1))==0) https://code.sololearn.com/cz5m85QG5aJw/?ref=app

8th Dec 2019, 1:19 PM
Kool
Kool - avatar
34 ответов
+ 11
Yes by checking like this. while(num > 0) { i = num % 10; if((i != 0) || (i != 1) { //Not binary number break; } j = num / 10; if(j == 0) { //Binary Number break; } }
8th Dec 2019, 2:31 PM
A͢J
A͢J - avatar
+ 9
Check here what I did. You have to return entered number not i Because you are checking Fibbinary Number on entered number. So I stored entered number in another variable n so we can return the exact entered value. We also can't return number because it's decreasing each time in loop so finally it will be 0 which we don't want. https://code.sololearn.com/cJYblftwbeBK/?ref=app
8th Dec 2019, 2:03 PM
A͢J
A͢J - avatar
+ 8
Alby check your code int n,i,result you didn't used result it's giving error correct your program.
9th Dec 2019, 5:34 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 8
Alby first understand number system conversion clear your concepts.
9th Dec 2019, 5:36 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 8
Alby Take one number convert it manually
9th Dec 2019, 5:39 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 8
Mike Abo Don't use such words keep this thread clean.Only ask proper questions in this thread.
9th Dec 2019, 9:40 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 7
Alby check the code which 🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! sent and ask your question properly don't get confused.
8th Dec 2019, 3:54 PM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 7
Show me that example then I will understand what's your exact problem right
9th Dec 2019, 5:39 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 6
Alby I already shown the code above. There we are doing both things checking Fibbinary Number as well as converting in Decimal Number. If we can check Fibbinary Number directly then why you are thinking to check converted binary number
8th Dec 2019, 3:30 PM
A͢J
A͢J - avatar
+ 6
Alby You got binary number in that code. Now you can check consecutive of 1 in that binary number if you found then it's not Fibbinary Number. Try to get it self.
8th Dec 2019, 8:59 PM
A͢J
A͢J - avatar
+ 6
Jack In this thread only ask proper questions don't chat here keep this thread clean.
10th Dec 2019, 2:11 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 5
Alby What do you want actually? You want Fibbinary Number or Check Binary Number or converted binary to decimal number. I think you are confused.
8th Dec 2019, 3:33 PM
A͢J
A͢J - avatar
+ 5
Alby 101 is Fibbinary Number. Check my code, run it and enter 5 then you will get.
9th Dec 2019, 5:10 AM
A͢J
A͢J - avatar
+ 5
Alby Input is 5, Binary Number of this input is 101 and 5 or 101 is Fibbinary Number. Why you are so confused bro.
9th Dec 2019, 5:20 AM
A͢J
A͢J - avatar
+ 5
Alby Go through this link and try to understand. http://www.c4learn.com/c-programming/c-bitwise-right-shift/
9th Dec 2019, 7:03 AM
A͢J
A͢J - avatar
+ 5
https://code.sololearn.com/cBnm3R056RoX/?ref=app Here's the code if you only need to check for Fibbinary Number <very short>
9th Dec 2019, 2:39 PM
Priyanshu Rai
Priyanshu Rai - avatar
+ 4
Thanks
8th Dec 2019, 1:44 PM
Kool
Kool - avatar
+ 4
Alby Check again and you still didn't update your code?
9th Dec 2019, 7:09 AM
A͢J
A͢J - avatar
9th Dec 2019, 7:11 AM
Kool
Kool - avatar
+ 3
After the conversion is there any way that the code checks the Converted [binary numbers] if it is a Fibbinary or not, rather than the Decimal? Help thanks.. If this will work Where im going to put Code i = num % 10 .... .... Where am i gonna put this? Is it going to replace if((n&(n>>1))==0) Or Is it going to replace conversion function [process]
8th Dec 2019, 3:00 PM
Kool
Kool - avatar