i know that if can be writen in short way syntax in c
please show me how
if arraeck(a, n) ? printf("YES") printf("NO");
some thing like this?..in one line…
What is the correct syntax
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Direct translation of your sample code:
Or even shorter:
This is called the (ternary) conditional operator
?:and it’s not always the best solution to use it, as it can be hard to read. You usually only use it if you need the result of the conditional, like in the second code sample (the operator evaluates to"YES"or"NO"here).In the first sample, the operator is not used as an an expression, so you should better use an explicit
if(it’s not that long after all):