Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.142.156.58
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/assign1a.cpp
//      File name:      assign1a.cpp
//      Author:         Benjamin Freeman
//      Instructor:     Dr. John Wang
//      Due date:       Wed., Feb. 6, 2008
//      Compilation:    g++ assign1a.cpp -o assign1a.out
//      Execution:      ./assign1a.out
//
//      Goal: This program will calculate the average of a group of numbers
//      and output the results as well as the largest number.


#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
	int num;
	float total = 0;	
	int size = 0;	
	float avg;
	int largest;
	cout << fixed << showpoint << setprecision(1);
	cout << "Input numbers & quit for a neg. one:\n";
	cin >> num;
	largest = num;
	while( num>0 )
	{	
		total = total + num;
		size ++;
		cin >> num;
		if( largest < num)
			largest = num;

	}
	
	avg = total / size;
	cout << "The average is: " << avg << endl;
	cout << "The largest number is: " << largest << endl;
	cout << "\n\n+++++++++\nDone.\n\n";
	return 0;
}


Stv3n404 - 2023