Created
April 25, 2013 05:37
-
-
Save gokhanyavas/5457715 to your computer and use it in GitHub Desktop.
Dışarıdan girilen N elemanlı bir dizinin aritmetik, geometrik ve harmonik ortalamasını hesaplayan program.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
#include<conio.h> | |
int main() | |
{ | |
int i,n; | |
int dizi[100]; | |
float ariort,geoort,harort; | |
ariort=0; | |
geoort=1; | |
harort=0.0; | |
printf("Dizinin eleman sayisini giriniz..:"); | |
scanf("%d",&n); | |
for(i=0;i<n;i++) | |
{ | |
printf("dizinin %d elemani :" ,i); | |
scanf("%d",&dizi[i]); | |
} | |
for(i=0;i<n;i++) | |
{ | |
ariort=ariort+dizi[i]; | |
geoort=geoort*dizi[i]; | |
harort=harort+1.0/dizi[i]; | |
} | |
ariort=ariort/n; | |
geoort=pow(geoort,(1/n)); | |
harort=n/harort; | |
printf("Aritmetik Ortalama=%f\n",ariort); | |
printf("Geometrik Ortalama=%f\n",geoort); | |
printf("Harmonik Ortalama =%f\n",harort); | |
getch(); | |
} |
Geometrik ortalamada hata oluyor
Hep 1 basıyor geoort da
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#include<stdio.h>
#include<math.h>
#include<conio.h>
int main()
{
int elemansay , i ;
float aritmetik = 0.0, geometrik , harmonik=0.0 , toplam = 0 , carpim = 1, harmo = 0.0;
printf("Dizinizin kac elemanli olacagini giriniz: ");
scanf("%d",&elemansay);
int dizi[elemansay];
}