Saturday, September 22, 2018

Array Mean

  • Problem Description

    Write a program to find the mean of the elements in the array.


    Input and Output Format:

    Input consists of n+1 integers where n corresponds to the number of elements in the array.

    The first integer corresponds to n and the next n integers correspond to the elements in the array.

    Output consists of a double value which corresponds to the mean of the array. It is printed upto 2 digits of precision.

    Assume that the maximum number of elements in the array is 20.

    Refer sample input and output for formatting specifications.

    All text in bold corresponds to input and the rest corresponds to output.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int i;
      float a,b[100],c=0;
      scanf("%f",&a);
      for(i=0;i<a;i++)
      {
        scanf("%f",&b[i]);
        c=c+b[i];
      }
      printf("The mean of the array is %.2f",c/a);
    return 0;
    }
  • Test Case 1

    Input (stdin)
    5
    
    2
    
    4
    
    1
    
    3
    
    5
    
    
    Expected Output
    The mean of the array is 3.00
  • Test Case 2

    Input (stdin)
    10
    
    100
    
    105
    
    200
    
    205
    
    108
    
    15
    
    18
    
    88
    
    1000
    
    12
    
    
    Expected Output
    The mean of the array is 185.10

1 comment:

  1. GRSoft Gaming is an honor winning, Live Casino game advancement organization of India. We offer curiosity and inventive game development with an exceptionally talented group of developer. Our bleeding edge gaming innovation creates esteem included gaming arrangements. Quality is our real worry for club game development. We offer tweaked Casino game development benefits over the globe and help you furnish with customized development. With our Casino game, individuals couldn't imagine anything better than to chance their gaining and appreciate the advantages. We have created numerous effective games like the video poker game, Sports wagering game, online club game, lottery games, and numerous other common games.

    Casino Games Software Developers UK, USA - Casino Game Development UK, USA

    ReplyDelete