I want to rewrite this code using ternary conditional operator ? : in c++ but I can't add new line (that is expressed by endl here) or concatenate the empty string
if (n % 10 == 0) {cout << n << endl;}
else {cout << n << " ";}
when is use this code
cout << (n % 10 == 0 ? n + "\n" : n + " ");
it doesn't produce the correct output it produces "@" (without double quotes) if I assign 10 to n and produce ",@" if I assign 11 to n