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 |
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); }
27 Answers Advent Global Solutions, CitiGroup, Valeo Lighting Systems India Private Limited, Vishal Transformers, Wipro, Zencer,
Explain about C function prototype?
Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: “jack and jill went up a hill” Return Value: “kcaj dna llij tnew pu a llih”
writw a program to insert an element in the begning of a doubly linked list
What is the code in while loop that returns the output of given code?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
main() {int a=200*200/100; printf("%d",a); }
Explain what is dynamic data structure?
Is there any possibility to create customized header file with c programming language?
what is the use of using linked list and array?
how can we print hellow world programme without using semicolon
Where is c used?