Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- int negCount = 0; // Negative numbers count
- int number; // Your input
- int numCount = 0; // Input count
- int sumOfNegetives = 0; // Do you want the sum(?)
- while(numCount < 5) // running 20 times
- {
- Console.Write("Enter a number: ");
- number = int.Parse(Console.ReadLine()); // receiving an input
- if(number < 0)
- {
- sumOfNegetives = number + sumOfNegetives; // Summing the negative numbers
- negCount++; // counts negative numbers
- }
- numCount++; // counts how many inputs you received
- }
- Console.WriteLine("there are: " + negCount + " negative numbers, " + "and their sum is:" + sumOfNegetives ); // print
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement