C
xxxxxxxxxx
int main() {
char operator;
double first, second;
printf("Enter an operator (+, -, *,): ");
scanf("%c", &operator);
printf("Enter two operands: ");
scanf("%lf %lf", &first, &second);
switch (operator) {
case '+':
printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
break;
case '*':
printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
break;
case '/':
printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
break;
// operator doesn't match any case constant
default:
printf("Error! operator is not correct");
}
return 0;
}
Enter an operator (+, -, *,): * Enter two operands: 1.5 4.5 1.5 * 4.5 = 6.8
Linux - anc-api-tools qanday o'rnatiladi
Linux - curvedns qanday o'rnatiladi
Python - Raqamning ijobiy, salbiy yoki 0 ekanligini tekshiring
Linux - zenmap qanday o'rnatiladi
C - Butun sondagi raqamlar sonini sanash
C++ - Raqam tub yoki oddiy emasligini tekshiring
C++ - Kabisa yilini tekshiring
C - Dinamik xotira ajratish yordamida eng katta raqamni toping
JavaScript - Satr ma'lum belgilar bilan boshlanishi va tugashini tekshiring
Kotlin - Raqamni teskari aylantirish
Linux - xbitmaps qanday o'rnatiladi
Linux - zstd qanday o'rnatiladi
Kotlin - Raqamni n o‘nlik kasrgacha yaxlitlash
Python - Excel (XLSX) fayllarini yozish
Java - Raqamni teskari aylantirish
C++ - Qism va qoldiqni toping
Kotlin - Sonning faktorialini toping
Java - Piramida va naqsh yarating
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month