# Untitled

unknown
plain_text
2 years ago
2.1 kB
2
Indexable
Never
```#include <stdio.h>
#include <math.h>

double runSubstraction(double x, double y);
double runMultiplication(double x, double y);
double runDivision(double x, double y);
double runPotency(double x, double y);
double runSquareRot(double x, double y);
double runReverse(double x, double y);

int main(void) {

char operator;
double start = 0.0;
double input;

while (1) {
printf("\nEnter operator, and an optional operand: \n");
scanf(" %c %lf", &operator, &input);

if (operator == '+') {
printf("Result so far is %lf", start);
}
else if (operator == '-') {
start = runSubstraction(start, input);
printf("Result so far is %lf", start);
}
else if (operator == '*') {
start = runMultiplication(start, input);
printf("Result so far is %lf", start);
}
else if (operator == '/') {
start = runDivision(start, input);
printf("Result so far is %lf", start);
}
else if (operator == '^') {
start = runPotency(start, input);
printf("Result so far is %lf", start);
}
else if (operator == '#') {
start = runSquareRot(start, input);
printf("Result so far is %lf", start);
}
else if (operator == 'q') {
return 0;
}
}
}

double runAddition(double x, double y) {
double result = x + y;
return result;
}

double runSubstraction(double x, double y) {
double result = x - y;
return result;
}

double runMultiplication(double x, double y) {
double result = x * y;
return result;
}

double runDivision(double x, double y) {
double result = x / y;
return result;
}

double runPotency(double x, double y) {
double result = pow(x, y);
return result;
}

double runSquareRot(double x, double y) {
double result = sqrt(x);
return result;
}
```