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"

{  
  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