What is the syntax for ternary operator in c?
Answers
Answered by
0
ternary operator used three operands..see syntax..a<b ? printf("a is less") : printf("a is greater");
Answered by
0
Ternary operator in C Programming Language
Explanation:
It is also identified as the Conditional Operator that is used at the place of If-else conditional statement because it is not different from the If-else conditional statement but It occupies minimum place also compose the if-else conditional statements as quickly as feasible.
Syntax:
variable_name = condition1 ? condition2 : condition3
Example:
#include <stdio.h> //header file
//define main method
int main(void)
{
int n, num1=5, num2=7; //declare variables
n = (num1>num2) ? num1 : num2; //ternary operator
printf("%d", n); //print result
return 0;
}
Output:
7
Learn More:
https://brainly.in/question/8418062
Similar questions
Geography,
7 months ago