/* June 14, 1998 */
/* Program to check whether the sum and product are equal using loop */


#include 

/* function prototype */
int add (int a);
int product (int b);

main ()
{

	/* declarations */
	int  n;
	
	/* request input */
	printf ("Enter a value of n> ");
        scanf ("%d", &n);

	/* display results */
        printf ("\nThe sum of 1 + 2 +...+ (n-1) + n = %d\n", add(n));
        printf ("The product of (n * (n+1)) is: %d\n", product (n));
        if (add(n) == product (n))
		printf ("...the sum and the product are equal!\n");
        else
                printf ("...the sum is not equal to the product!\n");

}

/* function definition */
int add (int a)

{
	/* local variable */
        int i;
	int sum;

	/* computation */
        sum = 0;
        for (i = a; i > 0; --i) {
		sum = sum + i;
        }

         return (sum);

}

/* function definition */
int product (int b)
{

       int c;

       c = (b * (b + 1)) / 2;

       return (c);
}


    Source: geocities.com/fire_168