Thread: C++ Help
View Single Post
  #25  
Old 04-27-2011, 04:22 PM
Divarin Divarin is offline
Kobold


Join Date: Jul 2010
Posts: 113
Default

here's a simple way to do part 1 without the need for an array
Code:
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int count, min, max, total;
	count=0;
	total=0;

	cout << "Please enter 5 numbers seperated by a space\n";
	while ( count < 5 )
	{
		int number;
		cin >> number;
		count++;
		if ( 1 == count )
		{
			min=number;
			max=number;
		}
		else
		{
			if ( number < min )
				min = number;
			if ( number > max )
				max = number;
		}
		total += number;
	}

	cout << " Lowest: " << min << endl 
		 << "Highest: " << max << endl
		 << "Average: " << total/5 << endl;
	
	system("pause");

	return 0;
}