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.
Answers were Sorted based on User's Feedback
Answer / devi
#include<stdio.h>
#include<conio.h>
void main()
{
int a[200],i,n;
float sum=0,avg;
clrscr();
printf("Enter the n values");
scanf("%d",&n);
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
avg=sum/n;
printf("Sum of %d array values is:%f",n,avg);
getch();
}
| Is This Answer Correct ? | 7 Yes | 5 No |
Answer / 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 |
What is the use of ?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
why in C,C++'s int size is 2 byte and .net(c#) int Size is 4 byte?
How can you read a directory in a C program?
we all know about the function overloading concept used in C++ and we all learnt abt that.... but that concept is already came in C in a very smaller propotion ... my question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION OVERLOADING IS USED in C language?????????????
where are auto variables stored? What are the characteristics of an auto variable?
how logic is used
What is the explanation for the dangling pointer in c?
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }
1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop
Difference between Class and Struct.
13 Answers Ericsson, Motorola, Wipro,
Is it fine to write void main () or main () in c?