Sunday, March 2, 2014

Conditional_OperatorExercises: (Wk-3), Jan 23, 2014

        static void Main(string[] args)
        {
            int x, y, z;
            //if statements to check whether
            // x <= 4 or y > 3 or z > y
            if (x <= 4 || y > 3 || z > y)
            { }
            else
            { }
            //========================================
            // x > (y+z) or y < z or z < 12
            if (x > (y + z) || y < z || z < 12)
            { }
            else
            { }
            //========================================
            // x is greater than 5 but less than 12
            if (x > 5 && x < 12)
            { }
            else
            { }
            //========================================
            // y is less than 10 or is greater than 22
            if ( y < 10 || y > 22)
            { }
            else
            { }
            //========================================
            // z is between 2 and 15
            if (z >= 2 && z <= 15)
            { }
            else
            { }
            //========================================
            // x is not less than 5
            if (x >= 5)
            { }
            else
            { }
            //========================================
            // y is not between 3 and 10
            if (y < 3 || y > 10)
            { }
            else
            { }
            //========================================
            // z is equal to 4, 7 or 12
            if (z == 4 || z == 7 || z == 12)
            { }
            else
            { }
            //========================================
            // x is different from 3 and 35
            if (x != 3 && x != 35)
            { }
            else
            { }
            //========================================
            //z is less than 5, or x is between 2 and 6
            if (z < 5 || (x > 2 && x < 6))
            { }
            else
            { }
            //========================================
            //z is greater than 10, and x is either greater than 15 or less than 6
            if (z > 10 && x > 15 || x < 6)
            { }
            else
            { }
            //========================================
            //twice z is not less than half y
            if ((z*2) >= y/2)
            { }
            else
            { }
            //========================================
            //x is not between -3 and 3, and x is different than 5
            if (x < -3 || x > 3 && x != 5)
            { }
            else
            { }
            //========================================
            //x + y is less than or equal to z-x/2
            if ((x + y) <= (z - x /2))
            { }
            else
            { }
            //========================================
            //x is between 3 and 5 and y is between -2 and 2
            if (x > 3 && x < 5 && y > -2 && y < 2)
            { }
            else
            { }
            //========================================
            // y is not equal to -5 or x is different from z
            if (y != -5 || x != z)
            { }
            else
            { }
            //========================================
            //z is between x and y and y is at least twice x
            if (z > x && z < y && y >= x + x)
            { }
            else
            { }
            //========================================
        }

No comments:

Post a Comment