0% found this document useful (0 votes)
19 views2 pages

Program 10

The document outlines a program that uses pointers to calculate the sum, mean, and standard deviation of an array of real numbers. It includes an algorithm and source code in C, detailing steps for inputting elements, performing calculations, and outputting results. The program is designed to handle a maximum of 10 elements and utilizes standard mathematical functions for computations.

Uploaded by

viveknaik2306
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Program 10

The document outlines a program that uses pointers to calculate the sum, mean, and standard deviation of an array of real numbers. It includes an algorithm and source code in C, detailing steps for inputting elements, performing calculations, and outputting results. The program is designed to handle a maximum of 10 elements and utilizes standard mathematical functions for computations.

Uploaded by

viveknaik2306
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Program10

Develop a program using pointers to compute the sum,mean and standard deviation
of all elements stored in an array of n real numbers.
Algorithm:To find sum,mean and standard deviation for ‘n’ number of:
Step 1: Start
Step2:[Input the [Link] elements]
Read n
Step3:[Input the ‘n’ number of elements]
for i=0 to n-1
Read a[i]
end for
Step4:[Assign the array elements to pointer ‘ptr’]
Ptr=a
Step5:[Calculate sum]
for i=0 to n-1
sum=sum+ptr[i]
end for
Step6:[Calculate mean]
Mean=sum/n
Step7:[Calculate sumstd]
for i=0 to n-1
sumstd=sumstd+pow((pow(ptr[i]-mean),2)
end for
Step8:[Calculate standard deviation std]
Std=sqrt(sumstd/n)
Step9:[Output sum,mean and standarddeviation] print
sum,mean,std
Step10: Stop
Source Code

#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
float a[10],*ptr,mean,std,sum=0,sumstd=0;
int i,n;
printf("enter the no of elements\n");
scanf("%d",&n);
printf("enter the array elements\n");
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
}
ptr=a;
for(i=0;i<n;i++)
{
sum=sum+ptr[i];
}
mean=sum/n;
for(i=0;i<n;i++)
{
sumstd=sumstd+pow((ptr[i]-mean),2);
}
std=sqrt(sumstd/n); printf("sum=%.3f\n",sum);
printf("mean=%.3f\n",mean); printf("standard deviation=%.3f\n",std);
getch();
}

You might also like