|
|
@ -2,10 +2,10 @@ |
|
|
|
|
|
|
|
// Function prototypes |
|
|
|
void displayMenu(); |
|
|
|
double add(int num1, int num2); |
|
|
|
double subtract(int num1, int num2); |
|
|
|
double multiply(int num1, int num2); |
|
|
|
double divide(int num1, int num2); |
|
|
|
double add(double num1, double num2); |
|
|
|
double subtract(double num1, double num2); |
|
|
|
double multiply(double num1, double num2); |
|
|
|
double divide(double num1, double num2); |
|
|
|
double exponent(double base, double exponent); |
|
|
|
double modulus(double num1, double num2); |
|
|
|
double logarithm(double num); |
|
|
@ -30,32 +30,32 @@ int main() { |
|
|
|
printf("Enter your choice: "); |
|
|
|
scanf("%d", &choice); |
|
|
|
switch (choice) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
printf("Enter two numbers: "); |
|
|
|
scanf("%d %d", &num1, &num2); |
|
|
|
scanf("%lf %lf", &num1, &num2); |
|
|
|
result = add(num1, num2); |
|
|
|
printf("Result: %d\n", result); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
printf("Enter two numbers: "); |
|
|
|
scanf("%d %d", &num1, &num2); |
|
|
|
scanf("%lf %lf", &num1, &num2); |
|
|
|
result = subtract(num1, num2); |
|
|
|
printf("Result: %d\n", result); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
printf("#Enter two numbers: "); |
|
|
|
scanf("%d %d", &num1, &num2); |
|
|
|
case 3: |
|
|
|
printf("Enter two numbers: "); |
|
|
|
scanf("%lf %lf", &num1, &num2); |
|
|
|
result = multiply(num1, num2); |
|
|
|
printf("Result: %d\n", result); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
printf("Enter two numbers: "); |
|
|
|
scanf("%d %d", &num1, &num2); |
|
|
|
scanf("%lf %lf", &num1, &num2); |
|
|
|
if (num2 == 0) { |
|
|
|
printf("Error: Division by zero\n"); |
|
|
|
} else { |
|
|
|
result = divide(num1, num2); |
|
|
|
printf("Result: %d\n", result); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
@ -118,25 +118,37 @@ int main() { |
|
|
|
result = permutation(n, r); |
|
|
|
printf("Permutation of %d and %d: %lf\n", n, r, result); |
|
|
|
break; |
|
|
|
case 19: |
|
|
|
case 15: |
|
|
|
printf("Enter n and r: "); |
|
|
|
scanf("%d %d", &n, &r); |
|
|
|
result = combination(n, r); |
|
|
|
printf("Combination of %d and %d: %lf\n", n, r, result); |
|
|
|
break; |
|
|
|
case 11: |
|
|
|
case 16: |
|
|
|
printf("Enter a number: "); |
|
|
|
scanf("%lf", &num1); |
|
|
|
result = cube(num1); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 12: |
|
|
|
case 17: |
|
|
|
printf("Enter a number: "); |
|
|
|
scanf("%lf", &num1); |
|
|
|
result = cubeRoot(num1); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case : |
|
|
|
case 18: |
|
|
|
printf("Enter a number: "); |
|
|
|
scanf("%lf", &num1); |
|
|
|
result = factorial(num1); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 19: |
|
|
|
printf("Enter base and exponent: "); |
|
|
|
scanf("%lf %lf", &num1, &num2); |
|
|
|
result = power(num1, num2); |
|
|
|
printf("Result: %lf\n", result); |
|
|
|
break; |
|
|
|
case 20: |
|
|
|
printf("Exiting...\n"); |
|
|
|
break; |
|
|
|
default: |
|
|
|