Create a code for C++ that can run with these descriptions below. Problem Descri
ID: 3532083 • Letter: C
Question
Create a code for C++ that can run with these descriptions below.
Problem Description:
Create a 1-D Array to hold a set of exam scores:
55 74 84 64 72 69 78 87 84 72 33 83 68 62 88 90
Write a program to do the following tasks:
1. Display scores in rows of four(4) scores.
2. Calculate average score and display.
3. Find Lowest score and display.
4. Find Highest score and display.
5. Find the deviation of each score, and
display the score and its deviation.
6. Find the Standard Deviation and Display
Coding: (Copy and Paste Source Code here)
Explanation / Answer
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int a[] = { 55, 74, 84, 64, 72, 69, 78, 87, 84, 72, 33, 83, 68, 62, 88, 90};
// 1. Display scores in rows of four(4) scores.
for(int i=0; i<16; i++)
{
if(i>0 && (i%4==0))
cout << endl;
cout << a[i] << " " ;
}
// 2. Calculate average score and display.
double sum = 0;
for(int i=0; i<16; i++)
sum = sum + a[i];
cout << " Average score is " << ( sum/16) << endl;
// 3. Find Lowest score and display.
int min = a[0];
for(int i=0; i<16; i++)
if(a[i] < min) min = a[i];
cout << "lowest score is " << min << endl;
// 4. Find Highest score and display.
int max = a[0];
for(int i=0; i<16; i++)
if(a[i] > max) max = a[i];
cout << "Highest score is " << max << endl;
// 5. Find the deviation of each score, and display the score and its deviation.
for(int i=0; i<16; i++)
{
// deivation from each score is
cout << a[i] << " is deviated " << (a[i]-sum/16) << endl;
}
// 6. Find the Standard Deviation and Display
double local_sum =0;
for(int i=0; i<16; i++)
{
local_sum = local_sum + ( a[i] - sum/16)*( a[i] - sum/16);
}
cout << " standard devation is "<< sqrt(local_sum)/15 << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.