63 195
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #23640 in C# for Sh

Question #23640
Write a C# program to count the number of negative numbers in a sequence of numbers the user inputs. In this solution, before reading the numbers, ask the user to input how many numbers will be input.
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Egative_numbers_in_a_sequence
{
class Program
{
static void Main(string[] args)
{
int number=0;
int countofnegetivenumbers = 0;
int inputnumber;
Console.Write("How many numbers will be input ");
number = int.Parse(Console.ReadLine());
for (int i = 0; i < number; i++) {
Console.Write("Enter number: ");
inputnumber = int.Parse(Console.ReadLine());
if (inputnumber < 0) {
countofnegetivenumbers++;
}
}
Console.Write("The number of negative numbers in a sequence are: " +
countofnegetivenumbers.ToString());
Console.ReadKey();



}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions