C program to add two numbers using recursive function




















Half Pyramid with Numbers. Print Colored Text in Python. Remove Numbers from String. Compare two Dates. Serialization and Deserialization. Java Library Functions. Basics Of Digital Components. Types of Computer Networks. Classical Synchronization Problem. What are Semaphores? Learn CSS. Learn JavaScript. C Language C Tutorial. C Compiler. Standard Template Library.

Python Python Tutorial. Python Programs. Python How Tos. Numpy Module. Convert Octal Number to Decimal and vice-versa. Calculate Average of Numbers Using Arrays.

Calculate Power Using Recursion. Share on:. Did you find this article helpful? Sorry about that. How can we improve it? Leave this field blank. Related Examples. But I have made one which works. So you can go through if it helps you correcting your code. Hope it helps. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?

Collectives on Stack Overflow. Learn more. Add only even numbers recursively Ask Question. Asked 8 years, 2 months ago. Active 8 years, 2 months ago.

Viewed 2k times. John Kugelman k 66 66 gold badges silver badges bronze badges. Jesse Upchurch Jesse Upchurch 91 8 8 bronze badges. Both your if branches execute the same call. So the if is totally useless. It's not totally useless; the printed output is different.

You're right though that it should be refactored so that there's just one call, and only the output is conditionalized. Add a comment. Active Oldest Votes. The logic needs two changes: If the first number is even then you want to add it to the sum, otherwise do nothing. John Kugelman John Kugelman k 66 66 gold badges silver badges bronze badges. This is what I like. I get a full explanation in English.



0コメント

  • 1000 / 1000