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

Between macros and functions,which is better to use and why?

1563


Difference between Shallow copy and Deep copy?

1562


What is the difference between array and pointer in c?

569


What are the benefits of c language?

638


How can you restore a redirected standard stream?

601






What is meant by realloc()?

666


How to throw some light on the b tree?

600


Explain #pragma statements.

598


What is signed and unsigned?

629


How many main () function we can have in a project?

603


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

734


Explain what are the advantages and disadvantages of a heap?

589


Explain what is the benefit of using const for declaring constants?

604


What is the difference between Printf(..) and sprint(...) ?

778


What is the code for 3 questions and answer check in VisualBasic.Net?

1682