196k views
0 votes
Please write a code for below:

Warren has declared and set two int variables named x and y. He wants the code to print "Larger" if x is strictly greater than y, and "Smaller" otherwise. But your code should not print anything unless a boolean flag variable named print is set to true.

User Gabriel Wu
by
3.0k points

1 Answer

1 vote

Answer:

int main()

{

int x,y;

bool b1, b2;

cout<<"enter values of x : ";

cin>>x;

cout<<"enter values of y : ";

cin>>y;

b1 = y > x; // false

b2 = x > y; // true

cout << "b1 is = " << b1 << "\\";

cout << "b2 is = " << b2 << "\\";

if (b2)

cout<<endl << "Larger Number" << "\\";

else

cout << "Smaller Number" << "\\";

return 0;

}

Please write a code for below: Warren has declared and set two int variables named-example-1
User Aarish Ramesh
by
4.0k points