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 |
C language questions for civil engineering
What is wrong with this program statement?
What are compound statements?
Is python a c language?
Why is C language being considered a middle level language?
How can I invoke another program from within a C program?
what is volatile in c language?
9 Answers Cap Gemini, HCL, Honeywell, TCS, Tech Mahindra,
HOW CAN ADD OUR FUNCTION IN LIBRARY.
What are the advantages of Macro over function?
diff. between *p and **p
There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.
What is Dynamic Initialization.