Hi,
Hope the stated 2 snippets are logically same.
But I am getting error for the second code snippet.
Generally the ternary operator statement is similar to a if else statement.
regarding the second code snippet, where by the continue keyword is used in the ternary opertor statement. It throws the C2059 error.
Why so ?
Please correct me if I am wrong.
Comments and guidance are welcome.
Thanks & Regards,
malini.k
code snippet 1
Int I =0;
While ( i<7)
{
I++;
If (I %2 == 0)
{
Continue;
}
else
{
Cout << I << endl;
}
}
Output: 1 3 5 7.
code snippet 2
int i = 0;
While ( I < 7)
{
I ++;
(I %2 == 0) ? continue : cout << i<< endl;
}