Write expression inside Ternary operator : Operator Ternary « Language Basics « C / ANSI-C






Write expression inside Ternary operator

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main(void)
{
  while(!kbhit()) 
      rand();

  rand() % 2 ? printf("H") : printf("T");

  return 0;
}


           
       








Related examples in the same category

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