Use Boolean variables with logical operators. - C Operator

C examples for Operator:Logic Operator

Description

Use Boolean variables with logical operators.

Demo Code

#include <stdio.h> 

int main(void) {

   int age = 6;//from ww  w .  j  a v  a2s.com

   int grade = 10;

   bool over_12 = age > 12;
   bool under_20 = age < 20;
   bool age_check = over_12 && under_20;
   bool grade_check = grade > 5;

   if (age_check || grade_check)
      printf("a teenager, or in school.");

   return 0;
}

Result


Related Tutorials