// Arup Guha
// 1/5/2013
// Solution to Programming Knights Practice Program Chapter 8 Problem 1
// Summing Even Numbers

#include <stdio.h>

int main() {

    // Get the user input.
    int n;
    printf("Enter a positive even integer.\n");
    scanf("%d", &n);

    // Add the desired numbers.
    int sum = 0, i;
    for (i=2; i<=n; i=i+2)
        sum = sum + i;

    // Another way to solve the problem, using the sum of an arithmetic series.
    // Note: This is faster...
    int alternateSolution = (n/2)*(n/2 + 1);

    printf("The desired sum is %d.\n", sum);
    printf("The direct solution yields %d.\n", alternateSolution);

    return 0;
}
