I need help with a programming assignment

User Generated

fryvfr

Programming

Description

  1. Paste the following code into the main() method.  Modify the code; so that it works (You’ll have to make 2 small modifications).  It should output the value of each string in the array called names.

string[] names = { "Al Dente", "Anna Graham", "Earle Bird", "Ginger Rayle", "Iona Ford" };

int i = 0;

while (i < names.Length)

{

  Console.WriteLine(names[0]);

}

2. Modify the code from problem 1, so that it outputs a number and then a person’s name using the following output statement.

Console.WriteLine("{0,2}. {1}", i, names[i]);

3. Modify the code from problem 6, so that it uses a foreach loop as opposed to a while loop.  The output should appear exactly the same as it did after step 2.


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Great! 10/10 would recommend using Studypool to help you study.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags