mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-21 21:11:57 +03:00
21 Oct
This commit is contained in:
parent
1f971098c4
commit
6f651d147c
45
QUARTILE.C
Normal file
45
QUARTILE.C
Normal file
@ -0,0 +1,45 @@
|
||||
#include<stdio.h>
|
||||
#include<conio.h>
|
||||
#include<math.h>
|
||||
void main()
|
||||
{
|
||||
int a[10],n,i,j,temp;
|
||||
float q1,q3,iqr;
|
||||
clrscr();
|
||||
printf("Enter no. for Random Numbers :");
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
a[i]=rand()%100;
|
||||
}
|
||||
printf("Random Numbers Generated are :\n");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("\n%d",a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\nSorted Data:");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
if(a[i]<a[j])
|
||||
{
|
||||
temp=a[i];
|
||||
a[i]=a[j];
|
||||
a[j]=temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("\n%d",a[i]);
|
||||
}
|
||||
q1=a[n/4];
|
||||
printf("\nFirst Quartile : %f",q1);
|
||||
q3=a[(3*n)/4];
|
||||
printf("\nThird Quartile : %f",q3);
|
||||
iqr=q3-q1;
|
||||
printf("\nInterQuartile Range is : %f",iqr);
|
||||
getch();
|
||||
}
|
56
VARIANCE.C
Normal file
56
VARIANCE.C
Normal file
@ -0,0 +1,56 @@
|
||||
#include<stdio.h>
|
||||
#include<conio.h>
|
||||
#include<math.h>
|
||||
void main()
|
||||
{
|
||||
int a[10],n,i,j,temp,sum=0;
|
||||
float mean,var,stand;
|
||||
clrscr();
|
||||
printf("Enter no. for Random Numbers :");
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
a[i]=rand()%100;
|
||||
}
|
||||
printf("Random Numbers Generated are :\n");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("\n%d",a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("\nSorted Data:");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
if(a[i]<a[j])
|
||||
{
|
||||
temp=a[i];
|
||||
a[i]=a[j];
|
||||
a[j]=temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("\n%d",a[i]);
|
||||
sum=sum+a[i];
|
||||
}
|
||||
mean=sum/(float)n;
|
||||
printf("\nMean :");
|
||||
printf("%f",mean);
|
||||
printf("\n");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
sum=sum+(pow((a[i]-mean),2));
|
||||
}
|
||||
var=sum/(float)n;
|
||||
printf("\nVariance is : %f",var);
|
||||
printf("\n");
|
||||
stand=sqrt(var);
|
||||
printf("\nStandard Deviation is : %f",stand);
|
||||
getch();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user