Answer to Question #56518 in C++ for Benjamin Amoasi

Question #56518
Write a simple application that accept 5 names from a user, and prints the names out in the reverse order. example Ben,Amavi,Peace,Amoo,Nester. Should be printed out as Nester,Amoo,Peace,Amavi and Ben.(Note use function to implement this program)
1
Expert's answer
2015-12-02T07:58:52-0500
using System;

namespace ReverseNamesOrder
{
class Program
{
static void Main(string[] args)
{
string[] names = new string[5];

// Read names
Console.WriteLine("Enter five names, please. One by line.");
for (int i = 0; i < 5; i++)
{
names[i] = Console.ReadLine();
}

// Write reverse order
Console.WriteLine();
Console.WriteLine("Reverse order: ");
for (int i = 4; i >=0; i--)
{
Console.WriteLine(names[i]);
}

// Delay
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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS