VelizarAvramov

09. Count the Integers

Nov 9th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._Count_the_Integers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int count = 0;
  10.  
  11.             while (true)
  12.             {
  13.                 try
  14.                 {
  15.                     string input = Console.ReadLine();
  16.                     int number = int.Parse(input);
  17.                     count++;
  18.                 }
  19.                 catch (Exception)
  20.                 {
  21.                     Console.WriteLine($"{count}");
  22.                     break;            
  23.                 }
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment