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

What is a far pointer in c?

0 Answers  


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

0 Answers   Wilco,


difference between function & structure

9 Answers   Verizon,


consagous technology placement paper

3 Answers   Consagous, Sypra,


in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?

11 Answers   IBM,






11. Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage

7 Answers   Accenture,


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

0 Answers  


Distinguish between actual and formal arguments.

0 Answers  


Why n++ execute faster than n+1 ?

2 Answers  


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CISOC, CitiGroup, College School Exams Tests,


what is computer

4 Answers  


who is the father of c

4 Answers   Infosys,


Categories