Monday, 15 January 2018

IO 6

QUESTION DESCRIPTION

Write a program by using all relational operators. 

Input and Output Format:

Refer sample input and output for formatting specification. All float values are displayed correct to 2 decimal places. All text in bold corresponds to input and the rest corresponds to output.

TEST CASE 1

INPUT

30 40

OUTPUT

Value of 30>40 is:0 
Value of 30>=40 is:0 
Value of 30<40 is:1 
Value of 30<=40 is:1

EXPLANATION :

The code requires you to accept 2 numbers from the user and check them for ">" , "<" , "<=" , ">=" and print '1' or '0' for "true" or "false" respectively according to the output format.


ALGORITHM :

This is a simple algorithm, as the result of the conditional statements (>,<,>=,<=) is an integer ("0" for "false" and "1" for "true"), we directly print the result of the conditional statements.

Steps :
  • Accept the values of first and the second number
  • Print the results of conditional statements in this order :
    • Greater than
    • Greater than equal to
    • Less than
    • Less than equal to

Remember the spacing in the output and the end of line


SOLUTION :  (Please use this as reference only)






No comments:

Post a Comment