/*
Write a function to return by its return statement the sum of the integers
from 1 to n, where n is a positive integer.
Write also a driver program to test the function.
Input: a positive integer n.
Output: the sum of the integers from 1 to n.
*/

#include <iostream>
using namespace std;

int sum(int n);

int main() 
{
	int n;
	cout << "Enter an integer: ";
	cin >> n; 
	if (n > 0)
		cout << sum(n) /* call statement */ << endl;
	else
		cout << n << " has to be a positive integer.\n";
	return 0;
}

// Definition of Function sum
int sum(int n) 
{
	int s = 0;
	for (int i = 1; i <= n; i++)
		s += i;
	return  s;
}
