If statement if语句中的错误

If statement if语句中的错误,if-statement,If Statement,我试着运行这段代码,但问题是——因为我是初学者——我不知道如何在一条if语句中放置几个条件,也不知道为什么if行和else链接有错误。你能告诉我哪里出错了吗?谢谢 #include <iostream> using namespace std; int main(){ double AVG; cout<< "please write in average\n"; cin>> AVG; if ((AVG >60) && (AVG >

我试着运行这段代码,但问题是——因为我是初学者——我不知道如何在一条if语句中放置几个条件,也不知道为什么if行和else链接有错误。你能告诉我哪里出错了吗?谢谢

#include <iostream>
using namespace std;
int main(){

double AVG;
cout<< "please write in average\n";
cin>> AVG;
if ((AVG >60) && (AVG >=90))----------expected identifier
    cout<< "pass with grade of " << AVG ;
    cout << "\n" << "A star!\n";
else----------------------------------expected expression
    cout << "fail with grade of " << AVG << "\n";
cout<< "good luck with your smester !\n";

}
#包括
使用名称空间std;
int main(){
双平均值;
cout>AVG;
如果((平均值>60)&&(平均值>=90))------------预期标识符

可能这对你有帮助,而且不需要添加
(AVG>60)和&(AVG>=90)
,就好像
AVG>=90
那么
AVG>60
已经是真的了

#include <iostream>
using namespace std;
int main(){

    double AVG;
    cout<< "please write in average\n";
    cin>> AVG;
    if (AVG >=90)
    {
        cout<< "pass with grade of " << AVG ;
        cout << "\n" << "A star!\n";
    }
    else
    {  
        cout << "fail with grade of " << AVG << "\n";
        cout<< "good luck with your smester !\n";
    } 
    return 0;
}
#包括
使用名称空间std;
int main(){
双平均值;
cout>AVG;
如果(平均值>=90)
{

cout如果使用多个语句,请使用括号,并且使用int main(),则需要返回一个值

更新代码

 #include <iostream>
 using namespace std;
 int main(){

    double AVG;
    cout<< "please write in average\n";
    cin>> AVG;
   if ((AVG >60) && (AVG >=90))
   {
     cout<< "pass with grade of " << AVG ;
     cout << "\n" << "A star!\n";
   }
 else{
    cout << "fail with grade of " << AVG << "\n";
     cout<< "good luck with your smester !\n";
  }
 return 0;
 }
#包括
使用名称空间std;
int main(){
双平均值;
cout>AVG;
如果((平均值>60)和&(平均值>=90))
{

旁注:我想你想在
if
下面加上大括号。旁注2:条件
(AVG>60)和&(AVG>=90)
有点可笑。我不明白,你能告诉我怎么做吗?旁注3:函数
main
应该返回一个值(通常
返回0;
足够好)。此答案不提供对
预期标识符
编译错误的解释。此答案不提供对
预期标识符
编译错误的解释。