I need help with the following assignment in C#. Suppose x, y, and z are int var
ID: 2247518 • Letter: I
Question
I need help with the following assignment in C#.
Suppose x, y, and z are int variables and x=12, y=34, and z=18. Determine if the following are true to false.
True or False?
!(x – y >= 1)
z <= 7 || y < 12
(x + y != 40) && (x != z)
(z – x >= y) || (y – x != z + 4)
(5 – x <= 2 * y) && (y – 15 >= z) || (x – 5 != y – 2 * z)
What text would be displayed in the label if the following code was run?
int count = 5;
lblTest.Text = “”;
while (count-- > 0)
lblTest.Text += count + “ ”;
What text would be displayed in the label if the following code was run?
int num = 1;
lblTest.Text = “”;
for (int i = 0; i < 5; i++)
{
num = num * (5 – i);
lblTest.Text += num + “ ”;
}
Write code that will reverse the digits of a number. For example, if num = 1234, then change num to 4321.
True or False?
!(x – y >= 1)
z <= 7 || y < 12
(x + y != 40) && (x != z)
(z – x >= y) || (y – x != z + 4)
(5 – x <= 2 * y) && (y – 15 >= z) || (x – 5 != y – 2 * z)
Explanation / Answer
1. True of False ----->
True or False
!(x – y >= 1)
True
z <= 7 || y < 12
False
(x + y != 40) && (x != z)
True
(z – x >= y) || (y – x != z + 4)
False
(5 – x <= 2 * y) && (y – 15 >= z) || (x – 5 != y – 2 * z)
True
2. Code ---->
int num = 1;
lblTest.Text = “”;
for (int i = 0; i < 5; i++)
{
num = num * (5 – i);
lblTest.Text += num + “ ”;
}
Output :-
10
3. Code ----->
int num = 1;
lblTest.Text = “”;
for (int i = 0; i < 5; i++)
{
num = num * (5 – i);
lblTest.Text += num + “ ”;
}
Output :-
15
ReverseNumber.cs ------->
using System;
namespace ReverseNumber
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a No. to reverse");
int Number = int.Parse(Console.ReadLine());
int Reverse = 0;
while(Number>0)
{
int remainder = Number % 10;
Reverse = (Reverse * 10) + remainder;
Number = Number / 10;
}
Console.WriteLine("Reverse No. is {0}",Reverse);
Console.ReadLine();
}
}
}
Output :-
True or False
!(x – y >= 1)
True
z <= 7 || y < 12
False
(x + y != 40) && (x != z)
True
(z – x >= y) || (y – x != z + 4)
False
(5 – x <= 2 * y) && (y – 15 >= z) || (x – 5 != y – 2 * z)
True