Question

Using c# Write a program that reads a collection of strings from the console and then...

Using c#

Write a program that reads a collection of strings from the console and then prints them onto the console. Each name should be printed on a new line.

Homework Answers

Answer #1
using System;

public class Main
{
    public static void Main(string[] args)
    {
        Console.Write("How many names do you want to enter? ");
        int n = Convert.ToInt32(Console.ReadLine());
        string[] names = new string[n];
        for (int i = 0; i < n; i++)
        {
            Console.Write("Enter a name: ");
            names[i] = Console.ReadLine();
        }

        Console.WriteLine("Names are:");
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(names[i]);
        }
    }
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The code needs to be in C #. Write a simple program that reads from the...
The code needs to be in C #. Write a simple program that reads from the console a set of numbers and prints back onto the console the smallest number from the collection
Java Program : Please save the program with the name ‘Dstring.java’ Write a program that reads...
Java Program : Please save the program with the name ‘Dstring.java’ Write a program that reads a string from the keyboard. If the length of the string is an even number, your program should split the string into two strings of equal length. If the length of the string is odd, your program should split the string into two strings where the first part has one more character than the second part. Your program should output the two strings it...
Write a java program that reads two sentences as strings, the program should print the common...
Write a java program that reads two sentences as strings, the program should print the common terms in both sentences example: input: I did my java homework yesterday yesterday i went to java island
Write a simple TCP program for a client that reads a line of text from its...
Write a simple TCP program for a client that reads a line of text from its standard input (keyboard) and sends the line out its socket to the server. The server reads the line from the socket and prints it in its standard output (screen). The server then reads a line from its standard input (keyboard) and sends it out its socket to the client. When the client sends “!” the server should reply back “bye” to the client and...
Create a new project in Visual Studio using C# Console Project. Declare an array of strings...
Create a new project in Visual Studio using C# Console Project. Declare an array of strings with the size of 12. Insert 12 different strings into the array. In a foreach loop display the contents of the array to the console.
Write a C++ program that reads two integers from the user. The program should tell whether...
Write a C++ program that reads two integers from the user. The program should tell whether the two numbers are equal or not.
Using a while loop, write a program that reads 10 integer numbers. The program shall count...
Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below. c++ language
C program question: Write a small C program connect.c that: 1. Initializes an array id of...
C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and changing all the entries with the same name as p to...
Write a program in C that does the following: Reads 10 real numbers from the keyboard...
Write a program in C that does the following: Reads 10 real numbers from the keyboard using a loop and displays the sum of the numbers and the sum of the square of the numbers.
Write an assembly program that reads characters from standard input until the “end of file” is...
Write an assembly program that reads characters from standard input until the “end of file” is reached. The input provided to the program contains A, C, T, and G characters. The file also may have new line characters (ASCII code 10 decimal), which should be skipped/ignored. The program then must print the count for each character. You can assume (in this whole assignment) that the input doe not contain any other kinds of characters.  the X86 assembly program that simply counts...