C program that allows the user to input scores and will output a table of scores with  the mean and standard deviation   Sample   Input Number of Students: 5   Input Score of Student 1: 5 Input Score of Student 2: 5 Input Score of Student 3: 5 Input Score of Student 4: 5 Input Score of Student 5: 5 5 5 5 5 5 Mean is 5 Sd is 0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

C program that allows the user to input scores and will output a table of scores with  the mean and standard deviation

 

Sample

 

Input Number of Students: 5

 

Input Score of Student 1: 5

Input Score of Student 2: 5

Input Score of Student 3: 5

Input Score of Student 4: 5

Input Score of Student 5: 5

5
5
5
5
5

Mean is 5

Sd is 0

Expert Solution
Step 1

PROGRAM STRUCTURE:

  • Include the required header files.
  • Start the definition of the main function.
    • Declare the required number of variables.
    • Take the number of students from the user.
    • Take the marks of the students.
    • Display the marks in the tabular form.
    • Calculate the mean and standard deviation using the given formula.
  • Display the result as mean and standard deviation.
Step 2

PROGRAM CODE:

#include <stdio.h>            // header file for standard input output
#include <math.h>           // header file for maths related functions
 
void main()                       // main function definition 
{
    int x[100], n, average, variance, std_deviation, sum = 0, sum1 = 0;       // variables
 
    printf("Input Number of Students: ");
    scanf("%d", &n);                                        // take number of students
    for (int i = 0; i < n; i++)
    {
        printf("Input Score of Student %d: ",i+1);
        scanf("%d", &x[i]);                                         // take score of the students
    }
    printf("\n _______\n");
    for(int i=0; i<n; i++)
    {
        printf("|%d\t|",x[i]);
        printf("\n _______\n");                                    // display the score in tabular form
    }
    for (int i = 0; i < n; i++)
    {
        sum = sum + x[i];                                       // calculates the sum
    }
    average = sum / n;                                         // calculates the average 
    for (int i = 0; i < n; i++)
    {
        sum1 = sum1 + pow((x[i] - average), 2);          
    }
    variance = sum1 / n;
    std_deviation = sqrt(variance);                            // calculate the standard deviation
    printf("\nMean is %d\n", average);                     // displays the results
    printf("Sd is %d\n", std_deviation); 
}

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education