【发布时间】:2019-11-21 19:42:52
【问题描述】:
我一直在使用三元运算符编写奇偶数代码,但它正在显示
"expected primary-expression before ‘?’ token"
我的代码:
{
int n;
cout<<"enter any numbner::";
cin>>n;
if(n%2==0) ? cout<<"no is even::" : cout<<"no is odd::";
return 0;
}
预期的 o/p 是:
enter any number:20
no is even::
【问题讨论】:
标签: c++ c++11 if-statement syntax conditional-operator