how to find sum of 5 digits in C?

Answer Posted / guest

#include<stdio.h>
int main()
{
int n,sum=0;
printf("enter number");
scanf("%d".&n);
for(int i=0;i<5;i++)
{
sum=sum+(n%10);
n=n/10;
}
printf("sum is %d",sum);
return 0;
}

Is This Answer Correct ?    16 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How variables are declared in c?

562


What are the different categories of functions in c?

639


What does static variable mean in c?

641


can anyone suggest some site name..where i can get some good data structure puzzles???

1637


write a progrmm in c language take user interface generate table using for loop?

1563






How to implement a packet in C

2383


Should a function contain a return statement if it does not return a value?

586


How can you check to see whether a symbol is defined?

583


How many bytes is a struct in c?

715


What is a lvalue

651


Explain null pointer.

612


Write a code of a general series where the next element is the sum of last k terms.

581


Which node is more powerful and can handle local information processing or graphics processing?

811


What is void pointers in c?

577


What is nested structure with example?

613