Use ternary operator in printf : Operator Ternary « Language Basics « C / ANSI-C






Use ternary operator in printf


#include <stdio.h>

int main(void)
{
  int x = 5, y = 10;

  printf("Max of %d and %d is: %d\n", x, y, (x>y ? x : y));

  return 0;
}


           
       








Related examples in the same category

1.Ternary (?) operator
2.Operator which accepts three value
3.Add function to the Ternary operator
4.Ternary operator inside if else
5.Simple Ternary operator
6.Write expression inside Ternary operator