12/14/2023 0 Comments 2 digit number brain out![]() Numerous people have answered the question already, but since every solution differs a bit, I'll just add mine as well. I know its a bit lengthy code, may be there are better solutions possible. its weird to print 0 ahead but it is defenitely needed here we are just checking first digit is 48 or not we added a 48 before all the digits in case there is an overall carry minus 48 to get the addition correct as we add 2 ascii numbers ]>] This is a special loop to traverse LEFT through indefinite no of 0s second input is over and terminated by an = symbol first input is over and terminated by a 'plus' symbol In documentation, I used 'plus' instead of + ,as + is a valid operation in bf. My answer in this question is one solution. First you need to know how to compare two numbers. Still I prefer NOT to look into my code, as designing by yourself is easier than studying or troubleshooting a code in bf. if you want to add 57 with 3, then give input like 57+03= or 03+57=. And make sure you use the same number of digits in both inputs. ![]() Only +ve numbers can be added in my code. First I thought the name of this PL is a bit offensive but now I know, if I was authorized to name this programming language, I'd choose the same. I saw this post 2-3 days ago and I've worked on it and now I have a solution on multi-digit addition. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |