Defines a series of variables and expressions and then uses both relational and logical operators to test them against each other - C Language Basics

C examples for Language Basics:Hello World

Description

Defines a series of variables and expressions and then uses both relational and logical operators to test them against each other

Demo Code

#include <stdio.h>
int main()//from   ww  w . j a v  a2  s  . c o  m
{
    int planets = 8;
    int friends = 6;
    int potterBooks = 7;
    int starWars = 6;
    int months = 12;
    int beatles = 4;
    int avengers = 6;
    int baseball = 9;
    int sum = 5;
    int total = 11;

    if ((friends + beatles >= baseball) && (friends + avengers >= total))
    {
        printf("1");
    }
    else
    {
        printf("2\n");
    }
    if ((starWars <= months) || (potterBooks <= months))
    {
        printf("3\n");
    }
    else
    {
        printf("4\n");
    }

    if (!(baseball + sum > total))
    {
        printf("5");
    }
    else
    {
        printf("\n6\n");
    }

    return 0;
}

Related Tutorials