高手帮忙指导一下我哪一步错了,后面软件报错啦(报错结果在代码最后)

#include <stdio.h>

#include <math.h>

void add(float a, float b) {

    printf("%.2f + %.2f = %.2f\n", a, b, a + b);

}

void subtract(float a, float b) {

    printf("%.2f - %.2f = %.2f\n", a, b, a - b);

}

 

void multiply(float a, float b) {

    printf("%.2f * %.2f = %.2f\n", a, b, a * b);

}

 

void divide(float a, float b) {

    if (b == 0) {

        printf("Error: division by zero\n");

        return;

    }

    printf("%.2f / %.2f = %.2f\n", a, b, a / b);

}

 

void power(float a, float b) {

    printf("%.2f ^ %.2f = %.2f\n", a, b, pow(a, b));

}

 

void root(float a, float b) {

    if (b == 0) {

        printf("Error: division by zero\n");

        return;

    }

    printf("%.2f ^ (1/%.2f) = %.2f\n", a, b, pow(a, 1/b));

}

 

void convert(int n, int base) {

    int rem, i = 0;

    char hex[20];

 

    while (n != 0) {

        rem = n % base;

        if (rem < 10) {

            hex[i] = rem + 48;

        } else {

            hex[i] = rem + 55;

        }

        i++;

        n /= base;

    }

    printf("Result = ");

    int j;

    for ( j = i - 1; j >= 0; j--) {

        printf("%c", hex[j]);

    }

    printf("\n");

}

 

void sin_func(float angle) {

    printf("sin(%.2f) = %.2f\n", angle, sin(angle));

}

 

void cos_func(float angle) {

    printf("cos(%.2f) = %.2f\n", angle, cos(angle));

}

 

void tan_func(float angle) {

    printf("tan(%.2f) = %.2f\n", angle, tan(angle));

}

 

void cot_func(float angle) {

    printf("cot(%.2f) = %.2f\n", angle, 1 / tan(angle));

}

 

int main() {

    int choice, n, base;

    float a, b, angle;

 

    printf("Welcome to the calculator!\n");

    do {

        printf("\n");

        printf("1. Addition\n");

        printf("2. Subtraction\n");

        printf("3. Multiplication\n");

        printf("4. Division\n");

        printf("5. Power\n");

        printf("6. Root\n");

        printf("7. Convert\n");

        printf("8. Sine\n");

        printf("9. Cosine\n");

        printf("10. Tangent\n");

        printf("11. Cotangent\n");

        printf("0. Exit\n");

        printf("Enter your choice: ");

        scanf("%d", &choice);

 

        switch (choice) {

            case 1:

                printf("Enter two numbers: ");

                scanf("%f %f", &a, &b);

                add;

            }

        }

    }

d55100f6f4134aefa67b0c04b156df49.jpg

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值