C printfs期望类型规范符



试图在这里找出我在C代码上做错了什么。最后两个printf调用是要求类型的指定符,我不知道该给它什么。其他行没有这个问题。任何帮助都将受到赞赏!

编辑程序执行多个数学函数,所讨论的两个打印行应该打印其中两个方程的结果。第一个应该打印用户输入的两个数字的其余部分,第二个printf应该打印出将两个数字添加在一起的答案,将其乘以第一个数字,然后将其除以第二个数字。这两种printf行都给我带来了e0079的错误,预期类型的指定符。

编辑2:通过更改项目的SDK包来解决此问题,并在询问用户的数字后将计算列出。吉米(Jimmy(的格式提示也有助于修复它。非常感谢所有帮助的人。

#include <stdio.h>
#include <stdlib.h>
main(void) {
    int digit1; //First digit user gives
    int digit2; //Second digit user gives.
    int product; //The result of the two user given numbers multiplied.
    int cube; //The result of cubing the second number.
    int remainder; //The remainder of dividing the two given numbers.
    int tooManySteps; //The result of adding the two given numbers together, multiplying it by the first given number, dividing by the second number.
    product = digit1 * digit2;
    cube = digit2 * digit2 * digit2;
    remainder = digit1 % digit2;
    tooManySteps = (digit1 + digit2) * digit1 / digit2;
    printf("Hi there, want me to do some cool math for you? Great! Just give me a number please.");
    scanf("%d", &digit1);
    printf("Cool! Now just give me one number.");
    scanf("%d", &digit2);
    printf("Your numbers multiplied together give you %d n", product);
    printf("Now the cube of the second number you gave is %d n", cube);
    printf("If you were to divide your two numbers together your remainder would be %dn", remainder);
    printf("Now we'll get really crazy, if you were to add your two numbers, multiply them by the first number you gave and divide by the second number you gave, you would get %dn", tooManySteps);
}

我真的认为这是一个不好的问题。但是我仍然为您更正代码。

int main(void)
{
    int digit1; //First digit user gives
    int digit2; //Second digit user gives.
    int product; //The result of the two user given numbers multiplied.
    int cube; //The result of cubing the second number.
    int remainder; //The remainder of dividing the two given numbers.
    int tooManySteps; //The result of adding the two given numbers together,
                      //multiplying it by the first given number, 
                      //dividing by the second number.
    printf("Hi there, want me to do some cool math for you? Great! "
           "Just give me a number please.");
    scanf("%d", &digit1);
    printf("Cool! Now just give me one number.");
    scanf("%d", &digit2);
    product = digit1 * digit2;
    cube = digit2 * digit2 * digit2;
    remainder = digit1 % digit2;
    tooManySteps = (digit1 + digit2) * digit1 / digit2;
    printf("Your numbers multiplied together give you %d n", product);
    printf("Now the cube of the second number you gave is %d n", cube);
    printf("If you were to divide your two numbers together your "
           "remainder would be %dn", remainder);
    printf("Now we'll get really crazy, if you were to add your two numbers, "
           "multiply them by the first number you gave and divide by the second"
           " number you gave, you would get %dn",
           tooManySteps);
    return 0;
}

最新更新