This program uses one dimensional array x to read the values and compute the sum of their squares.[Ansi C Program 7.1]

Sum of their Squares

Total = 10 i=1 ∑X2

The values of x1,x2 …… are read from the terminal.

Program :

#include<stdio.h>
int main()
{

    int i ;
    float x[10],value,total;
    /* Reading values into array */
    printf("Enter 10 real numbers\n");
    for(i=0;i<10;i++){
        scanf("%f",&value);
        x[i]=value;
    }
    /* Computation of total*/
    total = 0;
    for(i=0;i<10;i++){
        total = total + x[i] * x[i];
    }
    printf("\n");
    /* Printing Values and Total */
    for(i=0;i<10;i++){
            printf("x[%2d] = %5.2f\n",i+1,x[i]);
    }
        printf("Total = %.2f \n",total);
}