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
What is strcpy() function?
Differentiate between ordinary variable and pointer in c.
Explain what math functions are available for integers? For floating point?
How can I make sure that my program is the only one accessing a file?
What is the difference between exit() and _exit() function in c?
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?
#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); }
Which header file is used for clrscr?
how can f be used for both float and double arguments in printf? Are not they different types?
What is graph in c?
What does 3 mean in texting?
What is the best way of making my program efficient?
What is the difference between exit() and _exit() function?
Explain how does free() know explain how much memory to release?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..