Search
 
SCRIPT & CODE EXAMPLE
 

C

function for calculate the average and standard deviation of table

#include <stdio.h>
#include <math.h>
void The_Average(float *tab, int *length){
	float sum=0,sum2=0;
	for(int i=0;i<*length;i++){
		sum+=tab[i];
	}
	sum /=  *length;
	printf("The average of the table is : %.2f",sum);
	float tab2[*length],tab3[*length];
	for(int i=0;i<*length;i++){
		tab2[i]=tab[i]-sum;
		tab3[i]=pow(tab2[i],2);
		sum2+=tab3[i];
	}
	float result= sqrt(sum2 / (*length-1));
	printf("
the standard deviation is : %.2f",result);
}
int main(void) {
  int length ;
	float array[100];
	printf("enter the length of your table :");
	scanf("%d",&length);
	for(int i=0;i<length;i++){
		printf("enter the %d number :",i+1);
		scanf("%f",&array[i]);
	}
	The_Average(array,&length);
  return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: c if else 
C :: Syntax To Take Input In C 
C :: PATH_MAX 
C :: array value from user c 
C :: bash while loop n times 
C :: c memset 
C :: array reference argument 
C :: make a function makefile 
C :: double array in c 
C :: c recursion func revers number 
C :: hello word in c 
C :: C program to check whether character is lowercase or not using ASCII values 
C :: c convert float to string 
C :: bash get load average 
C :: doble puntero en c 
C :: clear screen in c 
C :: print to console in c 
C :: replace a substring with another substring in c 
C :: debian unhold packages 
C :: cifras de un numero en c 
C :: how to input till end of line in c 
C :: c pause for 1 second 
C :: bool c++ 
C :: static variable c 
C :: linear and binary search 
C :: c for result 
C :: program in c to print 1 to 100 without using loop 
C :: how can i learn c game development 
C :: phpunit assert continue 
C :: VLOOKUP CHECK #N/A 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =