I've been given an assignment in Uni to create a programme in C++ that can find the maximum and average of a set of values , inputted by the user. Now I've never done any C++ before so everythings a little new to me. I'm also at home today so I don't have visual c++ to test if everything's working properly. This is my code:
Thanks for any help , I need as much as I can get
As you can see there's probably a fair few errors in there but I just can't see them yet. The line ( for (count = 1; count <= set; count ++) ) is causing me a small bit of grief. Will the programme run everything in the count 1 loop and then increase the count by 1, or will it increase the count first. This would mean that the line "if ( count = 1 ); cout << " You have entered your 1st number. "; would never be seen.#include <iostream.h>
void main(void)
int set = 0;
{
int set = 0;
double one;
cout << "Type the amount of numbers you would like to enter: ";
cin >> set;
if (set = 1)
{
cout << " Please enter one number. "
cin >> one
cout << " Your average number is " << double one << ".";
cout << " Your maximum number must be " << double one << ", you've only entered one! " endl;
break
}
else if ( set != 1 );
cout << " Please enter " << set << " numbers. ";
else
cout << "\a";
double number = 0;
int count = 0;
double max = 0;
double total = 0;
cin >> number
for (count = 1; count <= set; count ++)
{
while (! good);
{
if (number >= 0 );
good = 1
else if ( number <= 0 );
good = 1
else cout << "\a";
}
if ( number <= max );
max = max;
else;
{
max = number;
count << " Your new maximum number is " << max << ".";
}
total = total + number;
if ( count == 1 );
cout << " You have entered your 1st number. ";
else if ( count == 2 );
cout << " You have entered your 2nd number. ";
else if ( count == 3 );
cout << " You have entered your 3rd number. ";
else
cout << " You have entered your << count << "th number. ";
}
cout << " You have finished entering your set. ";
cout << " Your maximum inputted value = " << max << ".";
cout << " Your average value was " << total/set << "." endl;
break;
Thanks for any help , I need as much as I can get