Saturday, May 21, 2011

C program to understand Single dimension array

Read values into an one dimensional array and compute the sum of
their squares


int main()
{
int a[100],i,j,b,sum=0;


printf("\nEnter the size of 1 dimensional array");
scanf("%d",&b);
printf("\nEnter the array");
for(i=0;i scanf("%d",&a[i]);
printf("\nThe sum of there squares is");
for(j=0;j {
sum=sum+pow(a[j],2);
}
printf("%d",sum);
system("pause");
return 0;
}

No comments:

Post a Comment