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 are lookup tables in c?

0 Answers  


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

0 Answers  


In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?

5 Answers  


Write a program to find given number is even or odd without using any control statement.

2 Answers  


What will be the output of the following program #include<stdio.h> void main() { int i=20; i-=i+++++i++; printf("%d",i); }

5 Answers  


#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?

4 Answers   Ramco,


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

0 Answers  


What is structure in c definition?

0 Answers  


What is the advantage of c?

0 Answers  


What are the 4 types of unions?

0 Answers  


What is an volatile variable?

15 Answers   HP,


How can I change the size of the dynamically allocated array?

0 Answers  


Categories