kevin
public cpp v1 · immutable/* * Kevin Stewart * COSC 1436, Northeast * Windows XP SP2 - Dev-C++ * Lab 6 , 9:21am, 5/3, 2007 * * Program Description--------------------------------- * Stores values into an array and computes them * * Program Design--Pseudocode * declartions of varibles begin * end */ #include <iostream> using namespace std; int main () //start of main function { int num_list[9]; cout<<"Enter values into an array" << endl; cout<<" " << endl; cout<<" " << endl; for(int i=0;i<10;i++) { cout<<"Enter value " << endl; cin>>num_list[i]; } //Values cout<<" " << endl; cout<<" " << endl; cout << "---------------------------------------------------" << endl; cout<<"Values" << endl; for(int i=0;i<10;i++) { cout << num_list[i] << endl; } cout<<" " << endl; //precent of total int total; float pre, pot; int smallest, largest; for(int i=0;i<10;i++) { total += num_list[i]; } cout << "Percent of Total" << endl; for(int i=0;i<10;i++) { pre = num_list[i] / total; pot = pre * 100; cout << pot << endl; } //RANGE cout << " " << endl; for(int i=0;i<10;i++) { for(int x=0; x<10; x++) { if (num_list[i] < smallest || i==0) smallest = num_list[i]; if (num_list[i] > largest || i==0) largest = num_list[i]; } } cout << "Values used range from " << smallest << " to " << largest << endl; //AVERAGE cout<<" " << endl; double average = total / 10; cout << "Average of the Ten Values = " << average << endl; cout<<" " << endl; //above average int above_average; cout << "Values above the Average" << endl; for(int i=0;i<10;i++) { if (num_list[i]>average) { cout << num_list[i] << endl; } } cout<<" " << endl; //class info cout << "KStewart S809L6.cpp" << endl; cout << "Lab#6 - NE 5/3/07" << endl; cout << "---------------------------------------------------" << endl; system ("pause"); return 0; }