Advertisement
skipter

C# Negative Elements in Array

Jun 23rd, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 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 _10.Negatives_Elem
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberOfTokens = int.Parse(Console.ReadLine());
  14.             int[] arrayToCheck = new int[numberOfTokens];
  15.  
  16.             int negativeCounter = 0;
  17.  
  18.             for (int cnt = 0; cnt < numberOfTokens; cnt++)
  19.             {
  20.                 arrayToCheck[cnt] = int.Parse(Console.ReadLine());
  21.                 if (arrayToCheck[cnt] < 0)
  22.                 {
  23.                     negativeCounter++;
  24.                 }
  25.             }
  26.             Console.WriteLine(negativeCounter);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement