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

In C language what is a 'dangling pointer'?

644


Who developed c language and when?

589


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

1589


What are the application of c?

652


What is logical error?

605






to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

1575


How do you search data in a data file using random access method?

840


What is calloc malloc realloc in c?

598


How can you find out how much memory is available?

620


write a program to concatenation the string using switch case?

1564


What is string function c?

573


What is a shell structure examples?

596


What is the importance of c in your views?

599


Why does everyone say not to use gets?

612


what is different between auto and local static? why should we use local static?

648