0% found this document useful (0 votes)
26 views

Coding 123

This C++ program allows the user to input multiple scores, calculates the average and standard deviation of those scores, and outputs the results. The program prompts the user for the number of scores, inputs each score in a loop, calculates the average by summing the scores and dividing by the total number, and then calculates the standard deviation by subtracting the average from each score, squaring the results, summing them, and taking the square root.

Uploaded by

Amanda Putri
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Coding 123

This C++ program allows the user to input multiple scores, calculates the average and standard deviation of those scores, and outputs the results. The program prompts the user for the number of scores, inputs each score in a loop, calculates the average by summing the scores and dividing by the total number, and then calculates the standard deviation by subtracting the average from each score, squaring the results, summing them, and taking the square root.

Uploaded by

Amanda Putri
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <math.h>
using namespace std;

int main() {

int a;
int b;

float score, average = 0, sum = 0, StandardDeviation;

cout << "How many scores/number of students are gonna be included?" << endl;

cin >> a;

float scores[a];

for (int b = 1; b <= a; b++) {

cout << "Insert number with index of " << b << " :" << endl;

cin >> score;

scores[b - 1] = score;

cout << "Avegage : ";

for (int b = 0; b < a; b++) {

average += scores[b];

average /= n;

cout << average << endl;

for (int b = 0; b < n; b++) {

scores[b] -= average;

scores[b] *= scores[b];

sum += scores[b];

sum /= a;

StandardDeviation = sqrt(sum);
cout << "Standard Deviation : " << sd << endl;

You might also like