Hi,
I Have tried to make average calculator but I cant make few things happen and I would really appreciate some help with this.
This is the code I came up with.
Questions are below.
#include <iostream>
using namespace std;
int main ()
{
int a, b;
float result;
cout << "Please enter first number" << endl;
cin >> a;
cout << "Please enter second number" << endl;
cin >> b;
cout << "Average is" << endl;
result = (a + b)/2.0;
cout << result << endl;
system ("pause");
return (0);
is it possible to input unlimited amount of nummbers nut just number 1 + number 2?
If yes then how ? for example 1+45+34, is there a way to define all positive numbers for example.
And how can I change result function so it understands how many numbers I have inputed and calculates the average value? IF its 1+45+34 the program understands that result should be (1+45+34)/3
If I input a letter instead of nummber how can I make it so program says that it is invalid input value or something like that ?
Thank you in advance,
And please dont be very harsh, i've been learning C++ for few weeks !
P.S Sorry for any english mistakes