Translate
Bu Blogda Ara
27 Temmuz 2018 Cuma
Calculator
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main(void)
{
char secim=0;
float sayi1,sayi2,toplam,fark,carp,bolum;
int top=0,fak=0,car=0,bol=0 ;
while(atoi(&secim)!=-1){
printf("Press\n1 for addition\n");
printf("2 for Subtraction \n");
printf("3 for Division\n");
printf("4 for Multiplication\n");
printf("-1 to Exit\n\n");
printf("Choose an operation");
scanf("%s",&secim);
if(atoi(&secim)>=0&&atoi(&secim)<=4){
printf("Enter first number:");
scanf("%f",&sayi1);
printf("Enter second number:");
scanf("%f",&sayi2);
}
system("cls");
if(atoi(&secim)==1){
top++;
system("cls");
toplam=(sayi1+sayi2);
printf("\n%.2f+%.2f=%f\n\n\n",sayi1,sayi2,toplam);
} else if(atoi(&secim)==2) {
fak++;
system("cls");
fark=sayi1-sayi2;
printf("\n(%.2f)-(%.2f)=%f\n\n\n",sayi1,sayi2,fark);
}
else if(atoi(&secim)==3) {
system("cls");
bolum=sayi1/sayi2;
printf("\n%.2f/%.2f=%f\n\n\n",sayi1,sayi2,bolum);
bol++;
}
else if(atoi(&secim)==4){
system("cls");
carp=sayi1*sayi2;
printf("\n%.2f*%.2f=%f\n\n\n",sayi1,sayi2,carp);
car++;
} else if(atoi(&secim)==-1)
break;
else{
system("cls");
printf("\nPlease enter one of these options 1 2 3 4 or -1\n");
}
}
printf("The number of\nAddition\t\t Multiplication\t\t Subtraction\t\t Division \n");
printf("%f \t\t %f \t\t %f \t\t %f",top,car,fak,bol);
return 0;
}
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder