w3resource

PHP Exercises: Check if y is greater than x, and z is greater than y from three given integers x,y,z

PHP Basic Algorithm: Exercise-47 with Solution

Write a PHP program to check if y is greater than x, and z is greater than y from three given integers x,y,z.

Sample Solution:

PHP Code :

<?php
// Define a function that checks if $x is less than $y and $y is less than $z
function test($x, $y, $z)
{
    // Check if $x is less than $y AND $y is less than $z
    return $x < $y && $y < $z;
}

// Test the function with different sets of numbers
var_dump(test(1, 2, 3))."\n";
var_dump(test(4, 5, 6))."\n";
var_dump(test(-1, 1, 0))."\n";
?>

Sample Output:

bool(true)
bool(true)
bool(false)

Visual Presentation:

PHP Basic Algorithm Exercises: Check if y is greater than x, and z is greater than y from three given integers x,y,z.

Flowchart:

Flowchart: Check if y is greater than x, and z is greater than y from three given integers x,y,z.

PHP Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a PHP program to check if it is possible to add two integers to get the third integer from three given integers.
Next: Write a PHP program to check if three given numbers are in strict increasing order, such as 4 7 15, or 45, 56, 67, but not 4 ,5, 8 or 6, 6, 8.However,if a fourth parameter is true, equality is allowed, such as 6, 6, 8 or 7, 7, 7.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.