Boolean Result C# Handson Solution Cognizant
Write a C# program to compare two numbers and print which number is lesser than the other.
Declare two variables an int x and int y. Obtain the value from the user for x and y. Write a program which tests whether x is less than y, storing the boolean result of this test into a bool variable named result. Print your findings, out to the console as given the sample output.
Sample Input:
Enter the value for x
5
Enter the value for y
7
Sample Output:
The result of whether x is less than y is true
Progran.cs
using System;
public class Program //DO NOT change the class name
{
static void Main(string[] args)
{
//implement code here
Console.WriteLine("Enter the value for x");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the value for y");
int y = Convert.ToInt32(Console.ReadLine());
bool result = x < y;
Console.WriteLine("x is less than y is " + result);
}
}
