feat: Initial commit

This commit is contained in:
2024-03-22 17:14:57 +01:00
parent dc83234df1
commit db9bafe755
45 changed files with 1996 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
#include <stdio.h>
int main()
{
char operation;
float op1, op2, res;
operation = getchar();
if (scanf("%f %f", &op1, &op2) != 2) {
printf("Error: Invalid input\n");
return 2;
}
switch (operation)
{
case '+':
res = op1 + op2;
break;
case '-':
res = op1 - op2;
break;
case '*':
res = op1 * op2;
break;
case '/':
if (op2 == 0) {
printf("Error: divide by zero\n");
return 2;
}
res = op1 / op2;
break;
default:
printf("Error: invalid operation\n");
return 1;
}
printf("%c %f\n", operation, res);
return 0;
}