write a program to gat the digt sum of a number (et. 15=
>1+5=6)

Answer Posted / sagarsp2010

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0,no;
clrscr();

printf("ENTER THE NO. OF TERMS:");
scanf("%d",&n);

for (i=1;i<=5;i++)
{

no=n%10;
sum=sum+no;
n=n/10;

}
printf("sum=%d",sum);

getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is strcpy() function?

657


Differentiate between ordinary variable and pointer in c.

617


Explain what math functions are available for integers? For floating point?

614


How can I make sure that my program is the only one accessing a file?

678


What is the difference between exit() and _exit() function in c?

584






Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

981


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

717


Which header file is used for clrscr?

582


how can f be used for both float and double arguments in printf? Are not they different types?

608


What is graph in c?

583


What does 3 mean in texting?

615


What is the best way of making my program efficient?

571


What is the difference between exit() and _exit() function?

606


Explain how does free() know explain how much memory to release?

575


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

646