小编use*_*516的帖子

编译C程序时不断出错:(

在编程时我完全没用,所以记住这一点!

我们必须编写一个生成两个随机数的代码,然后将这两个随机数传递给一个生成然后返回总和的函数.提示学生回答问题,如果他们弄错了,程序应该循环直到他们做对了,如果他们是正确的,程序应该循环并提出另一个问题.

当我编译时,我不断收到这些错误:

multi.c: In function ‘multiply’:
multi.c:6:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
multi.c:27:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
multi.c:31:1: error: expected ‘{’ at end of input
Run Code Online (Sandbox Code Playgroud)

这是我的代码,有人可以帮助我:

#include <stdio.h>

int multiply(int x, int y)

int main()
{
    int multiply(int x, int y);
    int x = rand()%20;
    int y = rand()%20;
    int i, answer;
    i = multiply(x,y);

    printf("what is %d multiplied by %d\n?" x, y);
    scanf("%d\n", &answer);

    while(answer …
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
343
查看次数

编译错误 - 数字常量

我在程序中不断收到以下编译错误.我想编写一个使用数组的程序,该程序p[]被传递给计算第n度多项式的函数(下面设置为5)并返回该值.

我的错误如下:

poly.c:4:39:错误:在数字常量之前预期';',','或')'

poly.c:16:39:错误:在数字常量之前预期';',','或')'

我的节目:

#include <stdio.h>
#define N 5

double eval(double p[], double x, int N)

int main()
{
    double p[N+1] = {0,1,2,3,4};
    double x;
    printf("what value of x would you like?: ");
    scanf("%lf", &x);
    p[N+1] = eval(p[], x, n);
    printf("%lf", p[N+1]);
}

double eval(double p[], double x, int N)
{
    double y;
    y = x^(p[N+1]);
    return y;
}
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
2251
查看次数

标签 统计

c ×2