In: Computer Science
The program asks user to enter three integers, and the displays a message indicating whether the numbers are in sequential order, in reverse order or in neither order. Find the errors and correct the program codes in the if comparison expressions. (10 points)
1. using System;
2. using static System.Console;
3.
4. class Sorting
5. {
6. static void Main()
7. {
8. int num1, num2, num3;
9. string snum1, snum2, snum3;
10. Write ("Enter first number ");
11. snum1 = ReadLine();
12. num1 = Convert.ToInt32(snum1);
13. Write ("Enter second number ");
14. snum2 = ReadLine();
15. num2 = Convert.ToInt32(snum2);
16. Write ("Enter third number ");
17. snum3 = ReadLine();
18. num3 = Convert.ToInt32(snum3);
19. if (num1 > num2 && num2 <= num3)
20. WriteLine ("Numbers are in sequential order");
21. else
22. if (num1 < num2 && num2 == num3)
23. WriteLine ("Numbers are in reverse order");
24. else
25. WriteLine ("Numbers are in neither sequential nor reverse order");
26. }
27. }
using System;
using static System.Console;
class Sorting{
static void Main()
{
int num1, num2, num3;
string snum1, snum2, snum3;
Write ("Enter first number ");
snum1 = ReadLine();
num1 = Convert.ToInt32(snum1);
Write ("Enter second number ");
snum2 = ReadLine();
num2 = Convert.ToInt32(snum2);
Write ("Enter third number ");
snum3 = ReadLine();
num3 = Convert.ToInt32(snum3);
// here we have to check the sequence
// like num1 should be less than num2 and num2 should be less than num3
if (num1 < num2 && num2 < num3)
WriteLine ("Numbers are in sequential order");
else
// here we should check of descending order
// num1 should be greater than num2 and num3
if (num1 > num2 && num2>num3)
WriteLine ("Numbers are in reverse order");
else
WriteLine ("Numbers are in neither sequential nor reverse order");
}
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME