Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- float add(float num1, float num2, float num3);
- float mult(float num1, float num2, float num3);
- float sub(float num1, float num2, float num3);
- void again();
- void again() {
- puts("returning to the main menu!\n");
- int main();
- }
- float add(float num1, float num2, float num3) {
- float ans = num1 + num2 + num3;
- return ans;
- }
- float mult(float num1, float num2, float num3) {
- float ans = num1 * num2 * num3;
- return ans;
- }
- float sub(float num1, float num2, float num3) {
- float ans = num1 - num2 - num3;
- return ans;
- }
- int main() {
- float num1, num2, num3;
- puts("Enter a b c\n");
- scanf_s("%f %f %f", &num1, &num2, &num3);
- int op;
- puts("Enter 1 for addition\nEnter 2 for multiplication\nEnter 3 for subtraction\n4 to return to main menu\n");
- scanf_s("%d", &op);
- if (op == 1) {
- float ans = add(num1, num2, num3);
- printf("result of op1: %f", ans);
- }
- else if (op == 2) {
- float ans = mult(num1, num2, num3);
- printf("result of op2: %f", ans);
- }
- else if (op == 3) {
- float ans = sub(num1, num2, num3);
- printf("result of op2: %lf", ans);
- }
- else if (op == 4) {
- again();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement