rado84

1st attempt

Jul 3rd, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace WHILE_OneToHundred
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Enter a number in the range [1...100]: ");
  14. int num = int.Parse(Console.ReadLine());
  15.  
  16.  
  17. while (true)
  18. {
  19. if (num >= 1 && num <= 100)
  20. {
  21. Console.WriteLine("The number is: " + num);
  22. }
  23.  
  24. else if (num < 1 || num > 100)
  25. {
  26. Console.WriteLine("Invalid number!");
  27. Console.WriteLine("Enter a number in the range [1...100]: ");
  28. Console.ReadLine();
  29. }
  30. break;
  31. }
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment