Search
 
SCRIPT & CODE EXAMPLE
 

C

function that returns the average of a given array of numbers

const average = arr => {
  const sum = arr.reduce((acc, num) => acc + num, 0)
  return sum / arr.length
}
Comment

program to find the average of n numbers using arrays.

// Program to find the average of n numbers using arrays

#include <stdio.h>
int main() {

  int marks[10], i, n, sum = 0, average;

  printf("Enter number of elements: ");
  scanf("%d", &n);

  for(i=0; i < n; ++i) {
    printf("Enter number%d: ",i+1);
    scanf("%d", &marks[i]);
          
    // adding integers entered by the user to the sum variable
    sum += marks[i];
  }

  average = sum / n;
  printf("Average = %d", average);

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: clear screen in c 
C :: dynamic memory allocation c 
C :: identifiers in c 
C :: check whether a number is prime or not in c 
C :: delay in c programming for windows 
C :: string array in c 
C :: print float in c 
C :: c median of an array 
C :: Program to Check Whether Character is Lowercase or Not without using islower function 
C :: Complete the function in the editor. It has one parameter: an array, . It must iterate through the array performing one of the following actions on each element: 
C :: C program to input the month number and output the month name using switch statement 
C :: powershell list big files 
C :: c str add int 
C :: print 100 times c 
C :: insert image material ui 
C :: fwrite c 
C :: oracle trunc 
C :: pointer in c 
C :: *= operator 
C :: pipe system call 
C :: entity framework core discard changes 
C :: c program boilerplate 
C :: Talk about the difference between call by reference and call by value and in C language with example? 
C :: epita 
C :: VLOOKUP CHECK #N/A 
C :: compil cywin cgi 
C :: which one is faster loop or recursive function? 
C :: passing an array to a function 
C :: lognormal distribution - matlab 
C :: unity read text file line by line 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =