answersLogoWhite

0


Best Answer

# include
void main()
{
int no,rem=0,sum=0,n; /*declaration*/
printf("Enter 2 digit number:");
scanf("%d",&no);
for(n=1;n<3;n++) /*conditions*/
{
rem=no%10; /*separation of digits using % and / */
sum=sum+rem;
no=no/10;
}
printf("sum=%d",sum);
}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

/*this v'll work to obtain sum of 1st and last number of any number */

#include

int main()

{

int num,sum=0,i,fd,ld;

printf("enter the number);

scanf("%d",&num);

ld=n%10; //will get the last digit

while(num!=0)

{

fd=n;

n/10; //to get the 1st digit

}

sum=fd+ld; //add 1st n last digit

printf("\n sum of 1st n last digit is %d",sum)

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<stdio.h>

int main()

{

int s,sum;

long num;

printf("enter the no:");

scanf("%ld",&num);

sum=num;

while(sum>10)

{

sum=0;

while(num!=0)

{

s=num%10;

sum=sum+s;

num=num/10;

}

num=sum;

}

printf("the single digit sum is :%d",sum);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

int Sum( int digits ) { if(digits < 10) return digits; return digits%10 + Sum(digits/10); }

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Something like this:

http://codepad.org/ua952rap

This answer is:
User Avatar

User Avatar

sujan

Lvl 2
2y ago

#include

Void main()

This answer is:
User Avatar
User Avatar

Arnulfo Macejkovic

Lvl 1
2y ago
awsome, ty
User Avatar

Holden Romaguera

Lvl 1
2y ago
Where did you find that?
User Avatar

Sabina Lindgren

Lvl 1
2y ago
are you sure?

Add your answer:

Earn +20 pts
Q: Program in c language to find sum of digits using recursion?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the C program for heap sort using recursion?

123


Write a program using recursion which should take two values and display 1st value raised to the power of second value?

Write a program using recursion which should take two values and display 1st value raised to the power of second value.


Can you implement merge sort without using recursion?

Sure, recursion can always be substituted with using a stack.


How many types of recursion are there in c language?

Recursion in c language is a method where the function calls itself, within or outside the scope. Using Recursion, complicated problems can be divided into smaller parts so that solving them becomes more manageable. The recursion technique is available in Java, JavaScript, and C++.serves the same purpose. The type of Recursion in C • Direct Recursion • Indirect Recursion. Direct Recursion Recursion can call the function n-number of times. In the case of direct Recursion, the function calls itself inside the same position or in the local scope Direct Recursion problems are the Fibonacci series, a program to print 50 natural numbers. Indirect Recursion In the case of Indirect Recursion, a function X calls function Y, and function Y calls any function Z. Under certain conditions, function Z calls function A. In this case, function A is indirectly related to function Z. Indirect Recursion is also known as mutual Recursion, as more than one function runs a program. It is a two-step recursive function call process for making a recursive function call. Below mentioned are also type of Recursion: Tail Recursion No Tail/Head Recursion Linear Recursion Tree Recursion Tail Recursion A function is said to be tail recursion if it calls itself and also calls the last or the previous statement executed in the process. Head Recursion A function is said to be Head Recursion if it calls itself and also calls the first or the beginning statement executed in the process. Linear Recursion A function is said to be a linear recursive function if it makes a single call to itself each time the procedure executes itself and grows linearly depending on the size of the problem. Tree Recursion Tree Recursion is different from linear Recursion. Rather than making only one call to itself, that function makes more than one recursive call to the process within the recursive function. Following are the steps to solve the recursive problem in C: Step 1: Create a function and assign the work a part should do. Step 2: Select the subproblem and assume that the function already works on the problem. Step 3: Get the answer to the subproblem and use it to resolve the main issue. Step 4: The 90% of the problem defined is solved.


Advantages and disadvantages of using recursion?

pata nhe


What are the merits and demerits of recursion?

Ans: Merits of recursion are: Mathematical functions, such as Fibonacci series generation can be easily implemented using recursion as compared to iteration technique. Demerits of recursion are: Many programming languages do not support recursion; hence, recursive mathematical function is implemented using iterative methods. Even though mathematical functions can be easily implemented using recursion, it is always at the cost of execution time and memory space. The recursive programs take considerably more storage and take more time during processing.


Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP


Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.


Can you provide a solution to the diamond-square algorithm using Java and recursion?

Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.


How do you write print 1 to 100 using recursion only?

recu


C program for summation of n nos using recursion?

int sum (int n) { if (n&lt;=1) return n; else return n + sum (n-1); }


Program to find sum of n numbers using recursion function?

int sum(n) { if (n==0) return 0; else return n+sum(n-1); }