jeudi 11 juillet 2019

I cant seem to get whats wrong with my code, I cant get the output

I have been writing this code of odd and even numbers using ternary operator but it is showing

"expected primary-expression before ‘?’ token"

My code:

{  
  int n;
  cout<<"enter any numbner::";
  cin>>n;

  if(n%2==0) ? cout<<"no is even::" : cout<<"no is odd::";

  return 0;
}

expected o/p is:

enter any number:20
no is even::

Aucun commentaire:

Enregistrer un commentaire