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.
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]); } } }
Get Answers For Free
Most questions answered within 1 hours.