Write a program which calculate sum of several number and input it into an array. Then, the sum of all the number in the array is calculated.
Answer Posted / pradeepnair
#include<stdio.h>
#include<conio.h>
void main()
{
int val1;
int val2;
int size=0;
int a,b[100];
int i,n,j,k=1;
int sum=0;
int sum1=0;
printf("enter the no of values to be added");
scanf("%d",&val1);
for(i=0;i<val1;i++)
{
scanf("%d",&a);
sum=sum+a;
}
System.out.println("the sum is"+sum);
while(sum>0)
{
val2 = sum%10;
sum=sum/10;
b[k]=val2;
size=size+1;
k--;
}
printf("the values in array are");
for(i=0;i<size;i++)
{
printf("/n",b[i]);
}
for(j=0;j<size;j++)
{
sum1=sum1+b[j];
}
printf("the sum of values an array is $d",sum1)
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Can a variable be both constant and volatile?
How can I direct output to the printer?
regarding pointers concept
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
What is a spanning Tree?
What is a pointer in c?
Add Two Numbers Without Using the Addition Operator
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
what is different between auto and local static? why should we use local static?
What is character constants?
What is bubble sort technique in c?
What is a global variable in c?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What is the use of pointers in C?
Why pointers are used?