how to find sum of 5 digits in C?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
Is there any demerits of using pointer?
What is the best organizational structure?
Write a program to add a given duration with time(24hrs format)
What is a pointer in c plus plus?
How variables are declared in c?
How can variables be characterized?
what would be the output of the following program? main() { int k = 123; char *ptr; ptr = &k; printf("%d",*ptr); }
What is the difference between File pointer and Internal Charecter Pointer?
Explain the difference between call by value and call by reference in c language?
What is the difference between text and binary modes?
i want to know the procedure of qualcomm for getting a job through offcampus
What is header file definition?