#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>
void menu();
int i, n;
int addition(int* );
int subtraction(int*);
int multiplication(int*);
double divide(int*);
int main(int argc, char* argv)
{
menu();
char secim;
char sorgu;
int sayi[2];
int sonuc=0;
//Kalin ayrac cizgi
for(i=0; i<60; i++)
{
printf("\xdb");
}
//Reng verme
system("color 9a");
printf("\n");
printf("\nBaslamak icin herhangi bir tusa basiniz.\n");
getch();
system("cls");
printf("\n");
for(i=0; i<60; i++)
{
printf("\xdb");
}
system("color 6b");
printf("\nHos Geldiniz\n");
for(i=0; i<60; i++)
{
printf("\xdb");
}
printf("\nHesaplma islemi yapiliyor.\n");
for(i=0; i<60; i++)
{
printf(".");
Sleep(30);
}
printf("\n");
menu();
do{
fflush(stdin);
printf("\nLutfen seciminizi yapiniz: ");
scanf("%c", &secim);
switch(secim){
case '1':
printf("Toplanacak sayilari giriniz: ");
for(i=0; i<2; i++)
scanf("%d", &sayi[i]);
for(i=0; i<2; i++)
sonuc=addition(&sayi[i]);
printf("Toplam sonucu: %d\n", sonuc);
break;
case '2':
printf("Cikarilacak sayilari giriniz: ");
for(i=0; i<2; i++)
scanf("%d", &sayi[i]);
for(i=0; i<2; i++)
sonuc= subtraction(&sayi[i]);
printf("Cikarma sonucu: %d\n", sonuc);
break;
case '3':
printf("Carpilacak sayilari giriniz: ");
for(i=0; i<2; i++)
scanf("%d", &sayi[i]);
for(i=0; i<2; i++)
sonuc= multiplication(&sayi[i]);
printf("Carpma sonucu: %d\n", sonuc);
break;
case '4':
printf("Bolme sayilari giriniz: ");
for(i=0; i<2; i++)
scanf("%d", &sayi[i]);
for(i=0; i<2; i++)
sonuc= divide(&sayi[i]);
printf("Bolme sonucu: %.2lf\n",(double)sonuc);
break;
case '5':
printf("Programdan cikildi.");
exit(0);
break;
default:
printf("hata\n");
//MessageBox(0, "Lutfen dort islem giriniz!\n(+, -, *, /)","Error!!",0);
break;
}
printf("\nPrograma devam edilmesini istermisin?(E(e)/H(h))");
sorgu= getche();
}while(sorgu =='e' || sorgu =='E');
return 0;
}
int addition(int* x){
int topla=0;
for(i=0; i<2; i++)
topla += x[i];
return topla;
}
int subtraction(int* x)
{
int cikarma=0;
x[i-1]=0;
for(i=0; i<2; i++)
cikarma= x[i-1]- x[i];
return cikarma;
}
int multiplication(int* x)
{
int carpma=1;
for(i=0; i<2; i++)
carpma *= x[i];
return carpma;
}
double divide(int* x)
{
int bolme=1;
x[i-1]=0;
for(i=0; i<2; i++)
bolme = x[i-1]/x[i];
return bolme;
}
void menu()
{
printf("\nLutfen dort islemden birini seciniz?");
printf("\n1-Toplam islemi");
printf("\n2-Cikarma islemi");
printf("\n3-Carpma islemi");
printf("\n4-Bolme islemi");
printf("\n5-Progmdan cikis\n");
}
Hiç yorum yok:
Yorum Gönder