Computer Science, asked by gaurishiarora488, 9 months ago

Assign x=6 and y=12, and print the output of the following comparisons in separate lines. x==y x!=y x>=y x>y x<=y x

Answers

Answered by codiepienagoya
0

Program to compare given values:

Output:

false

true

false

false

true

Explanation:

The program to compare the given values as follows:

Program:

//header file

#include <iostream> //defining header file

using namespace std;

int main() //defining main method

{

   int x=6,y=12; //defining integer variable

   string a; //defining string  

   a=(x==y) ?"true":"false"; //check condition and store output a variable  

   cout<<a<<"\n"; //print value

   a=(x!=y) ?"true":"false"; //check condition and store output a variable

   cout<<a<<"\n"; //print value

   a=(x>=y) ?"true":"false"; //check condition and store output a variable

   cout<<a<<"\n"; //print value

   a=(x>y) ?"true":"false"; //check condition and store output a variable

   cout<<a<<"\n"; //print value

   a=(x<=y) ?"true":"false"; //check condition and store output a variable

   cout<<a; //print value

return 0;

}

Explanation of the given program:

  • In the above C++ language program two integer variable "x and y" that hold a value which is "6 and 12". In the next line, a string variable "a" is declared, that holds condition return value.
  • To check the given condition the ternary operator is used that checks the given expression and the return value in the "true and false".  
  • If the condition is true or false, it will store in the string variable a and the print function(cout) is used to prints its value.

Learn more:    

  • what is comparisons: https://brainly.in/question/6921423
  • what is ternary operator: https://brainly.in/question/1404862
  • Use and syntax of ternary operator: https://brainly.in/question/4576461

Answered by protitisg
0

Answer:

Python code for this question

Explanation:

x=6

y=12

print(x==y)

print(x!=y)

print(x>=y)

print(x>y)

print(x<=y)

print(x<y)

The print statements will directly print True or False depending on values.

Similar questions