answersLogoWhite

0


Best Answer

/*Program in c to to find the sum and average of 1D array*/

#include<stdio.h>

#include<conio.h>

void main()

{

int a[5],i,sum;

float avg=0.0;

printf("Enter the elements of array");

for(i=0;i<5;i++)

scanf("%d" ,&a[i]);

sum=a[0]+a[1]+a[2]+a[3]+a[4];

printf("\n The sum of array is %d " ,sum);

printf("\n The average of array entered is %f ", avg);

getch();

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

Open a computer program like Visual Basic, Java, or C#, and then create an object and label it as an array. Input your 10 numbers into the object, then loop through each object in the array to find the sum, average, and mean by writing code in the program.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

In C:

#include <cstdio>

int main()

{

int num, odd, even;

printf("Enter 10 integers: \n");

for(int i = 0; i < 10; i++)

{

scanf("%d", &num);

if(num % 2 0)

{

even++;

}

}

odd = 10 - even;

cout << "Even: " << even << endl;

cout << "Odd: " << odd << endl;

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<stdio.h>

int main(){

int i=0,arr[10];

for(i=0;i<5;i++){

scanf("%d",&arr[i]);

}

for(i=0;i<6;i++){

printf("%d \n",arr[i]);

}

printf("\n");

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

#include<conio.h>

#include<stdio.h>

void main()

{

float num,avg,sum=0;

int count=1;

clrscr();

printf("Enter ten numbers: \n");

while(count<=10)

{

scanf("%d",&num);

sum+=num;

count++;

}

avg=sum/--count;

printf("\n\nThe sum of the ten numbers = %d",sum);

printf("\nThe average of the ten numbers = %d",avg);

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include

#include

void main()

{

int sum=0,avg=0,a[100],i=0,j=0,k=0;

printf("enter the number of elements wanna add");

scanf("%d",&n);

for(j=0;j<n;j++)

{

k=j+1;

printf("Enter rank %d element element ",k);

scanf("%d",&a[j]);

}

//for sum

for (i=0;i<100;i++)

{

sum=a[i]+sum;

}

printf("sum of nos %d",sum);

for (i=0;i<100;i++)

{

avg=sum/n;

}

printf("avg of nos",avg);

getch();

}

//you can change avg from int to float to get in decimals.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

double numbers[10] = { ... };

double sum = 0., mean;

int i;

for (i=0; i<10; i++) sum += numbers[i];

mean = sum / 10.;

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

#include <stdio.h>

int main (void)

{

int x=3, y=5;

printf ("sum=%d, average=%d\n", x+y, (x+y)/2);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

#include
#include
void main()
{
int i,sum=0;
for(i=1;i<=10;i++)
{
sum=sum+i;
}
printf("%d",sum);
getch();
}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The sum and average of a given number is just that number, so there is no need to write a program.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a c program to find sum and average of array elements?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


How are arrays processed?

Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.


Write a program to sort elements of an array in ascending order?

import java.util.Arrays; public class arraysort { public static void main(String[] a) { int array[] = { 2, 5, -2, 6, -3 }; Arrays.sort(array); for (int i : array) { System.out.println(i); } } }


Program in c to delete an element in sorted array?

You cannot delete elements from an array. But you can move the elements: if (del_index &lt; no_of_elements-1) { memmove (&amp;array [del_index], &amp;array [del_index+1], sizeof (array [0]) * (no_of_elements - del_index - 1)); } --no_of_elements;


What is array in program?

An aggregate of elements of the same type that occupy contiguous memory.


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


Program to print sorting of an array in clanguage?

/* PROGRAM TO SORT ARRAY ELEMENTS USING BUBBLE SORT*/ #include #include void main() { int i,j,n,t,a[50]; clrscr(); printf("ENTER THE ARRAY SIZE:\n"); scanf("%d",&amp;n); printf("ENTER THE ARRAY ELEMENTS:\n"); for(i=0;i


How do you write a C Program to fill up an Integer Array?

Reference:cprogramming-bd.com/c_page1.aspx# array programming


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


HOW TO SOLVE 'C' problem?

1. write a 'c' program to read 4(four)numbers from a file 'BANK' and calculate the average of the numbers.Now print the calculated average in another output file 'AVERAGE' 2. write a 'c' program that finds the sum and average of inputted five integer numbers of the array using dynamic memory allocation function malloc(). 3. write a 'c' program to create simple elements 1,2,3,4 in the link list of 4(four)nodes and display the list's elements. 4. write a 'c' program to convert the expression (A+B)/(C+D) into postfix expression into stack.and then evaluate it for A=10,B=20,C=15,D=5 and display the stack status after each operation. 5. write a 'c' programto create a linked list implemented on an array containing the following numbers:1,2,3,3,3,4,4,9 and pack it to remove the duplicate numbers.so that only the following data are contained by the nodes:1,2,3,4,9


How do you write a program that accepts 50 integer values and sort them in basic programming?

Create an array with 50 elements and input the integers one a time, filling the array. Use an insertion sort on the array for each input except the first. Alternatively, input the values first and then use insertion sort.


Write a program to add array of N elements?

int sumArray(int N, int* A) { int sum = 0; do sum += A[N-1] while (N-- &gt; 1); return sum; }