Operators Used in if Comparisons - C Statement

C examples for Statement:if

Introduction

ComparisonMeaning or Pronunciation "True" Examples
< Less than 1 < 5
==Equal to 5 == 5
>Greater than 8 > 5
<= Less than or equal to 4 <= 5
>= Greater than or equal to 9 >= 5
!= Not equal to 1 != 0

Demo Code

#include <stdio.h>
#include <stdlib.h>
int main()// w w  w  .j av a2  s .c o  m
{
   int tax1,tax2;
   char height[4],temp[4],favnum[5];
   printf("Enter your height in inches:");
   gets_s(height);
   printf("What temperature is it outside?");
   gets_s(temp);
   printf("Enter your favorite number:");
   gets_s(favnum);
   tax1 = atoi(height) * atoi(favnum);
   tax2 = atoi(temp) * atoi(favnum);
   if(tax1>tax2)
   {
      printf("You owe $%d in taxes.\n",tax1*10);
   }
   if(tax2>=tax1)
   {
      printf("You owe $%d in taxes.\n",tax2*10);
   }
   return(0);
}

Result


Related Tutorials