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 |
Which of the following is not a valid declaration for main ()? 1) int main() 2) int main(int argc, char *argv[]) 3) They both work
What is clrscr ()?
write a program to convert a expression in polish notation (postfix) to inline (normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix
what type of language is C?
convert 12345 to 54321 withoutusing strig
Describe advantages and disadvantages of the various stock sorting algorithms
count the numbers between 100 and 300, that star with 2 and ends with 2
how many argument we can pas in in a function
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +
what is memory leak?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What is difference between array and structure in c?