/*4)	Write a program to read a positive integer N. 
If the user enters a non positive integer, you should ask him/her to 
enter again. 
If N is positive, read N real numbers and compute and display the 
average of the 
positive numbers entered.
*/

#include <iostream>
using namespace std;
int main()
{
	int N, i, count;
	float x, sum;
	cout << "Enter a positive integer: ";
	cin >> N;
	while (N <= 0)
	{
		cout << "Enter a positive integer: ";
		cin >> N;
	}
	sum = 0;
	count = 0;
	i = 1; // initialization
	while (i <= N)
	{
		cout << "Enter a real number: ";
		cin >> x;
		if (x > 0)
		{
			sum = sum + x; // sum += x; // Shortcut operator
			count = count++; // count = count + 1;
		}
		i++; // update action
	}
	if (count > 0)
		cout << "The average of the positive numbers "
			<< "entered is: " << sum / count << endl;
	else
		cout << "No positive numbers entered.\n";
	return 0;
}
