veronikaaa86

09. Count the Integers

Jan 31st, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. namespace Ex9_CountTheIntegers
  2. {
  3.     using System;
  4.     public class Program
  5.     {
  6.         public static void Main(string[] args)
  7.         {
  8.             int counter = 0;
  9.             int num = 0;
  10.  
  11.             for (int i = 0; ; i++)
  12.             {
  13.                 try
  14.                 {
  15.                     num = int.Parse(Console.ReadLine());
  16.                     counter++;
  17.                 }
  18.                 catch (Exception)
  19.                 {
  20.                     break;
  21.                 }
  22.             }
  23.  
  24.             Console.WriteLine(counter);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment