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

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); }

27 Answers   Advent Global Solutions, CitiGroup, Valeo Lighting Systems India Private Limited, Vishal Transformers, Wipro, Zencer,


Explain about C function prototype?

0 Answers  


Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”

5 Answers   Mind Tree,


writw a program to insert an element in the begning of a doubly linked list

1 Answers  


What is the code in while loop that returns the output of given code?

0 Answers  






Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

0 Answers  


main() {int a=200*200/100; printf("%d",a); }

14 Answers   TCS,


Explain what is dynamic data structure?

0 Answers  


Is there any possibility to create customized header file with c programming language?

0 Answers  


what is the use of using linked list and array?

10 Answers   Infosys, TCS,


how can we print  hellow world programme without using semicolon

3 Answers  


Where is c used?

0 Answers  


Categories