Summation of a bunch of numbers is very typical problem in computation.

To sum up 10 numbers, we do

#include <stdio.h>

int main()
{
    int number;
    int i,sum;

    sum = 0;
    for (i = 0;i < 10;i++)
    {    
        scanf("%d",&number);
        sum = sum + number;
    }
    printf("The sum is %d.\n",sum);

    return 0;
}

stdin


 
1 2 3 4 5 6 7 8 9 10

stdout


 
The sum is 55.

You have no rights to post comments