Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. Console.Write("Enter a natural number: ");
  8. int n = int.Parse(Console.ReadLine());
  9. int broika = 0;
  10.  
  11. if (n > 0 && n % 1 == 0)
  12. {
  13. for (int i = 0; i <= n; i++)
  14. {
  15. Console.Write("Enter a 4-digit natural number: ");
  16. int num = int.Parse(Console.ReadLine());
  17. if (num >= 1000 && num <= 9999)
  18. {
  19. if (num / 100 % 10 == 0) {
  20. broika++;
  21. }
  22. } else {
  23. Console.WriteLine("The number that you have entered is not a 4-digit natural number");
  24. break;
  25. }
  26. }
  27. Console.WriteLine(broika);
  28. } else
  29. Console.WriteLine( "The number that you have entered is not natural." ) ; } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement