In: Computer Science
Answer : Algorithm
Step 1:Take 2 integers i, and sum. i for loop counter variable and sum for storing the sum of squares of all 10 integers.initially initialize the sum to 0
Step 2: Take input of 10 numbers and store them in an array a[10];
Step 3: For each elements in array perform following:
sum=sum+ a[i]*a[i];// where a[i] is the ith element in the array
Step 4: Print the value of sum as the sum of squares of 10 entered integers.
A C program for the above algorithm is:
#include<stdio.h>
main()
{
int
n,i,sum, a[10];
i=1,sum=0;
while
(i<=n)
{ scanf(%d,&a[i]);
}
while
(i<=10)
{
sum=sum+i*i;
++i;
}
printf
(
"Sum
of squares of numbers from 1 to n is :%d
"
,sum);
}