## Practice Exercises C# Sharp

Learn to program performing exercises with C# Sharp

## 12 Lessons C# Sharp with the Solutions - 228 Exercises C# Sharp with the solutions For Beginners, Intermediates and Advanceds

The human knowledge belongs to the world
¡The infomation should be free!

5 Estrellas - 9986Total Votos

# Array of positive and negative numbers - Practice Exercises C# Sharp

## Source Code:

```using System;
public class ArrayOfPositiveAndNegative
{
public static void Main()
{
float[] numbers = new float[10];
float totalPositive = 0.0f;
float totalNegative = 0.0f;
int countPositive = 0;
int countNegative = 0;

for (int i=0;i < 10;i++)
{
Console.Write("Number {0}= ",i+1);
}

for (int i=0;i < 10;i++)
{
//Negative
if (numbers[i] < 0)
{
totalNegative = totalNegative + numbers[i];
countNegative++;

//Positive
if (numbers[i] > 0)
{
totalPositive = totalPositive + numbers[i];
countPositive++;
}
Console.WriteLine("Average numbers negatives = {0}",totalNegative /
countNegative);
Console.WriteLine("Average numbers positives = {0}",totalPositive /
countPositive);
}
}

```
Exercisey 4.4