The following C program is used to evaluate the following expression:
Total = Σ i=110 Xi2
where X1, X2 … X10 they are user inputs.
The code has been tested in Dev c++.
CODE:
#include<stdio.h>
void main(){
int i;
float x[10],value,total;
printf("Enter 10 REAL Numbers");
for(i=0;i<10;i++){
scanf("%f",&value);
x[i]=value;
}
total=0.0;
for(i=0;i<10;i++){
total = total +x[i]*x[i];
printf("\n");
}
for(i=0;i<10;i++){
printf("x[%d] = %5.2f\n",i+1,x[i]);
}
printf("total=%.2f\n",total);
}
OUTPUT:
