how to find sum of 5 digits in C?

Answers were Sorted based on User's Feedback



how to find sum of 5 digits in C? ..

Answer / 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

how to find sum of 5 digits in C? ..

Answer / deepshree sinha

#include<stdio.h>
#include,conio.h>
void main()
{
int i,a[6],s=0;
printf("enter the values");
for(i=0;i<5;i++)
{
scanf("%d ",7a[i]);
s=s+a[i];
}
printf("sum of five digits=%d',s);
getch();
}

Is This Answer Correct ?    2 Yes 1 No

how to find sum of 5 digits in C? ..

Answer / rohit

#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;
}
printf("sum is %d",sum);
return 0;
}

Is This Answer Correct ?    2 Yes 3 No

how to find sum of 5 digits in C? ..

Answer / my yahoo id

1+2+3+4+5=15

Is This Answer Correct ?    2 Yes 12 No

Post New Answer

More C Interview Questions

C language questions for civil engineering

0 Answers   Tech Mahindra,


What is wrong with this program statement?

0 Answers  


What are compound statements?

0 Answers  


Is python a c language?

0 Answers  


Why is C language being considered a middle level language?

0 Answers  






How can I invoke another program from within a C program?

8 Answers  


what is volatile in c language?

9 Answers   Cap Gemini, HCL, Honeywell, TCS, Tech Mahindra,


HOW CAN ADD OUR FUNCTION IN LIBRARY.

5 Answers  


What are the advantages of Macro over function?

1 Answers  


diff. between *p and **p

3 Answers  


There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


What is Dynamic Initialization.

3 Answers  


Categories