how to find sum of digits in C?

Answer Posted / leelanarasimhareddy

void main()
{
int a[20];
printf("enter no of values");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("%d",sum);
}

Is This Answer Correct ?    63 Yes 86 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the concatenation operator?

628


What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

683


Write a program on swapping (100, 50)

640


Explain About fork()?

653


What is meant by keywords in c?

620






What is sizeof array in c?

597


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

650


What does s c mean on snapchat?

590


What are header files in c programming?

660


Can a void pointer point to a function?

579


What is a scope resolution operator in c?

756


What is identifiers in c with examples?

680


Can we declare function inside main?

572


How do I get an accurate error status return from system on ms-dos?

653


Explain the use of 'auto' keyword

683