Ternary operator

I was given this block of code and I don't really understand it. I was told it's the same as an If Else statement. Could someone write this as an If Else statement so it's easier for me to understand it?

1
2
( i == j || i + j == n + 1 ) ? printf( "*" ) : printf( " " );
printf( "\n" );
1
2
3
4
if ( i == j || i + j == n + 1 ) 
    printf( "*" );
else
    printf( " " );


How about doing an elementary search to see if someone has already written something? This website has a search function and "ternary" is a feasible keyword.
Topic archived. No new replies allowed.