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

program for validity of triangle from 3 side

7 Answers  


What is optimization in c?

0 Answers  


write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?

3 Answers   Mind Tree,


How pointers are declared?

0 Answers  


what is the output of printf("%d",(scanf("%d",10));

10 Answers  






write a C program : To find out the number of identical words in two files . the file name should be taken as command line argument .

1 Answers   Subex,


What is the purpose of clrscr () printf () and getch ()?

0 Answers  


What is the sizeof () a pointer?

0 Answers  


What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?

1 Answers  


What is the use of structure padding in c?

0 Answers  


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

0 Answers   MNC,


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

0 Answers  


Categories