Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / sanjay m
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int n,c=0,r,i,S=0;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(n>0)
{
{
r=n%10;
c=c+r;
n=n/10;
}
if(c>9)
{
int X=c%10;
int Y=c/10;
S=X+Y;
}
}
if(c<10)
printf("%d",c);
else
printf("%d",S);
getch();
}
Is This Answer Correct ? | 13 Yes | 14 No |
Post New Answer View All Answers
Write a program to identify if a given binary tree is balanced or not.
Explain threaded binary trees?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
hi send me sample aptitude papers of cts?
When should I declare a function?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
What is the function of multilevel pointer in c?
What is a nested loop?
Is array a primitive data type in c?
Compare and contrast compilers from interpreters.
Should I learn c before c++?
What do the functions atoi(), itoa() and gcvt() do?
What is #define size in c?
What are pointers? What are different types of pointers?