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
FILE PROGRAMMING
How many levels of indirection in pointers can you have in a single declaration?
Does c have function or method?
When should a far pointer be used?
In a byte, what is the maximum decimal number that you can accommodate?
What is the use of gets and puts?
What is c mainly used for?
Explain what is the difference between text files and binary files?
What is oops c?
Function calling procedures? and their differences? Why should one go for Call by Reference?
Explain bit masking in c?
Write a program to reverse a linked list in c.
What is the difference between strcpy() and memcpy() function in c programming?
Can we compile a program without main() function?
What is #include stdlib h?