#include <stdio.h>
#include <conio.h>
#include <math.h>
float a, b, c, u, alan, cevre;
double d;
int sayac=0, secim;
void ucgen();
void heron();
void tabanyuk();
void daire();
void dairealan();
void dairecevre();
void menu();
void topla();
void atopla();
void cikar();
void carp();
void bol();
void kbol();
void usal();
void pisagor();
void faktoriyel();
void menu()
{
printf("\n\n[1]Toplama\n");
printf("[2]Ardisik toplama\n");
printf("[3]Cikarma\n");
printf("[4]Carpma\n");
printf("[5]Bolme\n");
printf("[6]Kalansiz bolme\n");
printf("[7]Us alma\n");
printf("[8]Pisagor\n");
printf("[9]Ucgenin alani\n");
printf("[10]Daire alan ve cevre\n");
printf("[11]Faktoriyel\n");
printf("\nIstediginiz bolumu girin:");
scanf("%d", &secim);
if(secim==1)
{
secim=0;
topla();
}
else if(secim==2)
{
secim=0;
atopla();
}
else if(secim==3)
{
secim=0;
cikar();
}
else if(secim==4)
{
secim=0;
carp();
}
else if(secim==5)
{
secim=0;
bol();
}
else if(secim==6)
{
secim=0;
kbol();
}
else if(secim==7)
{
secim=0;
usal();
}
else if(secim==8)
{
secim=0;
pisagor();
}
else if(secim==9)
{
secim=0;
ucgen();
}
else if(secim==10)
{
secim=0;
daire();
}
else if(secim==11)
{
secim=0;
faktoriyel();
}
else
exit(0);
}
/************************************************************/
/*Üçgen*/
void ucgen()
{
printf("\nUcgenin alanini bulma\n\n");
printf("[1]Heron formulu ile\n");
printf("[2]Taban x yukseklik\n");
printf("Islem secin:");
scanf("%s", &secim);
switch(secim)
{
case '1':heron();break;
case '2':tabanyuk();break;
default:exit(0);break;
}
}
/************************************************************/
/*Heron*/
void heron()
{
printf("\nBirinci kenari girin:");
scanf("%f", &a);
printf("\nIkinci kenari girin:");
scanf("%f", &b);
printf("\nUcuncu kenari girin:");
scanf("%f", &c);
u=(a+b+c)/2;
alan=sqrt(u*(u-a)*(u-b)*(u-c));
if(alan==(int)alan)
{
printf("\nUcgenin alani:%0.0f", alan);
menu();
}
else if(alan==(float)alan)
{
printf("\nUcgenin alani:%f", alan);
menu();
}
}
/************************************************************/
/*taban x yükseklik*/
void tabanyuk()
{
printf("\nTaban uzunlugunu girin:");
scanf("%f", &a);
printf("\nYuksekligi girin:");
scanf("%f", &b);
alan=a*b/2;
if(alan==(int)alan)
{
printf("\nUcgenin alani:%0.0f", alan);
menu();
}
else if(alan==(float)alan)
{
printf("\nUcgenin alani:%f", alan);
menu();
}
}
/************************************************************/
/*daire*/
void daire()
{
printf("\n[1]Daire alani\n");
printf("[2]Daire cevresi\n");
printf("Islem secin:");
scanf("%s", &secim);
switch(secim)
{
case '1':dairealan();break;
case '2':dairecevre();break;
default:exit(0);break;
}
}
/************************************************************/
/*dairealan*/
void dairealan()
{
printf("\nDairenin yaricapini girin:");
scanf("%f", &a);
alan=a*a*M_PI;
printf("\nDairenin alani:%f", alan);
menu();
}
/************************************************************/
/*dairecevre*/
void dairecevre()
{
printf("\nDairenin yaricapini girin:");
scanf("%f", &a);
cevre=2*M_PI*a;
printf("\nDairenin cevresi:%f", cevre);
menu();
}
/************************************************************/
/*toplama*/
void topla()
{
printf("\nToplama islemini sectiniz\n");
printf("\nKac tane sayi toplamak istiyorsunuz:");
scanf("%f", &c);
printf("\nToplamak istediginiz sayilari girin:");
b=0;
while(c!=sayac)
{
sayac++;
scanf("%f", &a);
b=b+a;
if(sayac==c)
break;
}
sayac=0;
if(b==(int)b)
{
printf("\nSonuc:%0.0f", b);
menu();
}
else if(b==(float)b)
{
printf("\nSonuc:%f", b);
menu();
}
}
/************************************************************/
/*ardışık toplama*/
void atopla()
{
printf("\nArdisik toplama islemini sectiniz\n");
printf("\n1'den kaca kadar toplama istiyorsunuz:");
scanf("%f", &c);
b=0;
for(a=1;a<=c;a++)
b=b+a;
printf("\nSonuc:%0.0f", b);
menu();
}
/************************************************************/
/*çıkarma*/
void cikar()
{
printf("\nCikarma islemini sectiniz\n");
printf("\nBirinci sayiyi girin:");
scanf("%f", &a);
printf("\nIkinci sayiyi girin:");
scanf("%f", &b);
c=a-b;
if(c==(int)c)
{
printf("\nSonuc:%0.0f", c);
menu();
}
else if(c==(float)c)
{
printf("\nSonuc:%f", c);
menu();
}
}
/************************************************************/
/*çarpma*/
void carp()
{
printf("\nCarpma islemini sectiniz\n");
printf("\nKac tane sayiyi carpmak istiyorsunuz:");
scanf("%f", &c);
printf("\nCarpmak istediginiz sayilari girin:");
b=1;
while(c!=sayac)
{
++sayac;
scanf("%f", &a);
b=b*a;
if(sayac==c)
break;
}
sayac=0;
if(b==(int)b)
{
printf("\nSonuc:%0.0f", b);
menu();
}
else if(b==(float)b)
{
printf("\nSonuc:%f", b);
menu();
}
}
/************************************************************/
/*bölme*/
void bol()
{
printf("\nBolme islemini sectiniz\n");
printf("\nBirinci sayiyi girin:");
scanf("%f", &a);
printf("\nIkinci sayiyi girin:");
scanf("%f", &b);
c=a/b;
if(b==0 && a==(int)a)
{
printf("\n%0.0f sifira bolunemez", a);
menu();
}
else if(b==0 && a==(float)a)
{
printf("\n%f sifira bolunemez", a);
menu();
}
if(c==(int)c)
{
printf("\nSonuc:%0.0f", c);
menu();
}
else if(c==(float)c)
{
printf("\nSonuc:%f", c);
menu();
}
}
/************************************************************/
/*kalansız bölme*/
void kbol()
{
printf("\nKalansiz bolme islemini sectiniz\n");
printf("\nBirinci sayiyi girin:");
scanf("%f", &a);
printf("\nIkinci sayiyi girin:");
scanf("%f", &b);
d=fmod(a,b);
c=(a-d)/b;
if(b==0 && a==(int)a)
{
printf("\n%0.0f sifira bolunemez", a);
menu();
}
else if(b==0 && a==(float)a)
{
printf("\n%f sifira bolunemez", a);
menu();
}
else
{
printf("\nSonuc:%0.0f", c);
menu();
}
}
/************************************************************/
/*üs alma*/
void usal()
{
printf("\nTaban degerini girin:");
scanf("%f", &a);
printf("\nUs degerini girin:");
scanf("%f", &b);
c=pow(a,b);
if(c==(int)c)
{
printf("\nSonuc:%0.0f", c);
menu();
}
else if(c==(float)c)
{
printf("\nSonuc:%f", c);
menu();
}
}
/************************************************************/
/*pisagor*/
void pisagor()
{
printf("\nBirinci dik kenari girin:");
scanf("%f", &a);
printf("\nIkinci dik kenari girin:");
scanf("%f", &b);
c=sqrt((a*a)+(b*b));
if(c==(int)c)
{
printf("\nHipotenus:%0.0f", c);
menu();
}
else if(c==(float)c)
{
printf("\nHipotenus:%f", c);
menu();
}
}
/************************************************************/
/*faktoriyel*/
void faktoriyel()
{
printf("\nFaktoriyeli alinacak sayiyi girin:");
scanf("%f", &a);
d=1;
for(b=a;b>0;b--)
d*=b;
printf("\nSonuc:%0.0f", d);
menu();
}
main()
{
system("title Hesaplayıcı");
printf("********Hesaplayici********");
menu();
return 0;
}
doğan
dogan.332@hotmail.com