10 Answers
New AnswerI created a program using the Recursive procedure to calculate the sum of two numbers, but when I use variables a and b when a = 2 and b = 3 then the result is not 6.
4/16/2021 6:24:53 AM
Puspa Sari10 Answers
New AnswerI don't understand ... You said the code was supposed to "sum two numbers". So let <a> be 2, and <b> be 3, Now you add the two, obviously you should get 5 rather than 6. Except if you meant to multiply ...
Ipang well. he said to use recursive procedure. i tried doing what he had given aand it gave an segmentation error
Coding Kitty You probably didn't have a base case in whatever you were doing (I don't how you can add 2 numbers using recursion, 3 or more I can understand). No base case means infinite recursion, means stack overflow, means segmentation fault.
Ipang sorry, I was wrong. multiply two numbers with the addition concept that I entered.
Hi Puspa, Are you using array to do this? cause my idea is only based on the use of an array for this.
Puspa Sari, In case you haven't gotten it figured out, this one gives an example without use of array. https://www.studytonight.com/c/programs/recursion/adding-two-numbers-using-recursion
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message