Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.72.44
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/grpatillo/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/grpatillo/hw1_212a.cpp
/*	File Name:	hw1_212a.cpp
	Author:		R.P. Patillo
	Due Date:	February 6, 2008
	Compilation:	g++ hw1_212a.cpp -o hw1_212a.out
	Execution:	./hw1_212a.out

	Goal:		The goal is to allow the user to input natural  			     numbers and display the smallest value and average 			  value.
*/
#include <iostream>
#include <iomanip>

using namespace std;

const int M = 100;

int main()
{	
	int arr[M];
	int size = 0;
	int total = 0;
	int largest, smallest;
	double avg;
	string line = "======================";
	cout << fixed << showpoint << setprecision(1);	

	cout << "Input numbers & neg. to quit.\n";
	cin >> arr[size];
	largest = arr[size];
	smallest = arr[size];

	while (arr[size] > 0)
        {       if ( largest < arr[size] )
                        largest = arr[size];
                else if( smallest > arr[size] )
                        smallest = arr[size];
                total = total + arr[size];
                size ++;
                cin >> arr[size];
        }
        avg = total / size;
	
	cout << "Total = " << total << ", size = " << size << endl;
	cout << line << endl;
	cout << "The average value = " << avg << endl;
	cout << "The smallest = " << smallest << endl;
	cout << "The largest = " << largest << endl;
	cout << "\n\n" << line << "\nDone.\n\n";
	return 0;
}

Stv3n404 - 2023