Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CountOfDifferentIntegers
- {
- class CountOfNumbers
- {
- static void Main(string[] args)
- {
- int[] arr = new int[] { -2, 1, 3, -5, 0, 9, 0, -6, -102 };
- int countOfPositive = 0;
- int countOfNegative = 0;
- int countOfZero = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] > 0)
- {
- countOfPositive++;
- }
- else if (arr[i] < 0)
- {
- countOfNegative++;
- }
- else
- {
- countOfZero++;
- }
- }
- Console.WriteLine("Number of positive numbers: " + countOfPositive);
- Console.WriteLine("Number of negative numbers: " + countOfNegative);
- Console.WriteLine("Number of zeros: " + countOfZero);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment