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 |
program for validity of triangle from 3 side
What is optimization in c?
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?
How pointers are declared?
what is the output of printf("%d",(scanf("%d",10));
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 .
What is the purpose of clrscr () printf () and getch ()?
What is the sizeof () a pointer?
What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?
What is the use of structure padding in c?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
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 ?