gpt4 book ai didi

c - 什么是错误 : expected ')' before ';' token|

转载 作者:太空宇宙 更新时间:2023-11-04 07:49:04 24 4
gpt4 key购买 nike

I'm doing a small starter project for my school,and im kinda new to all the programing,now when i try to build my program it says that i need ")" before ";" in line 21 and its asking for "";" before the "}" in line 22" and i have checked and there is a ";" before "}" but looks like my codeblocks is not recognizing it,or its just me being blind or me without a brain. Thanks for looking at my question.

实际错误代码

21|error: expected ')' before ';' token
22|error: expected ';' before '}' token

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()

{
int f,x;

printf("Type in values of x: ");

scanf("%d",&x);

if (x <= 1)

{(f = -2 * x);
printf("%d",f);}

else
printf("Its not possible to do this function");


if (1 < x < 5)

{(f = sqrt(pow(x, 3)-(2*x));
printf("%d",f);}

else
printf("Its not possible to do this function");

return 0;
}

最佳答案

Clang 救援:

error: expected ‘)’ before ‘;’ token
(f = sqrt(pow(x, 3) - (2 * x));
^

您缺少结束符 )。顺便说一下,那里根本不需要那对大括号:

 if (x > 1 && x < 5) // <-- BTW, the corrected condition
{
f = sqrt(pow(x, 3)-(2*x));
printf("%d",f);
}
else
{ // <-- better to use braces symmetrically in if-else
printf("Its not possible to do this function");
}

关于c - 什么是错误 : expected ')' before ';' token|,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55014089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com