{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

homework9

# homework9 - ECE 1574 Homework Set#9 Problem Solving with C...

This preview shows pages 1–3. Sign up to view the full content.

ECE 1574 Homework Set #9 Problem Solving with C++ Due date: 3/28/10 by 11:55 p.m. This assignment is to be done individually Complete the lab exercise and answer questions 1 and 2 during the lab session. Answer the other questions later. LAB EXERCISE 1. Use the statement int set [20]; Write a program that uses pointers to store the value 0 in the first ten elements of the array and 99 in the second 10 elements of the array. Output the values of the array to the screen and capture the output as part of your solution. #include <iostream> using std::cout; using std::endl; int main() { int set[20]; int *p = set; for ( int i = 0; i < 10; i++) *(p+i) = 0; for ( int i = 10; i < 20; i++) *(p+i) = 99; for ( int i = 0; i < 20; i++) cout << set[i] << endl; return 0; } 2. Write a program that dynamically allocates an array large enough to hold a user- defined number of test scores. Once all of the scores are entered, the array should be passed to a function that sorts them into descending order. Another function should calculate the average score. A third function should calculate the standard deviation for the scores. The program should display the sorted list of scores, the average, and the standard deviation. Use pointer notation rather than arrays. Be sure that your program dynamically allocates enough memory to handle the number of values that a user might want to enter. The first number a user enters tells the program how many scores will be entered. Be sure that your program checks to ensure that input values are between 0 and 100 inclusive. Supply at least three sets of input data and display the corresponding output to convince us that your program works properly.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
#include <iostream> #include <cmath> using std::cout; using std::endl; using std::cin; double average( double testgrades[], int num ); double stddeviation ( double testgrades[], int
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}