I asked this once before but it came up incorrect somehow so I'll submit this one again. Write a program in C# named ArrayDemo that stores an array of 10 integers. (Note that the array is created for you and does not need to be changed.) Until the user enters a sentinel value, allow the user four options: (1) to view the list in order from the first to last position in the stored array (2) to view the list in order from the last to first position (3) to choose a specific position to view (4) to quit the application. -------- using System; using static System.Console; class ArrayDemo {    static void Main()    {        int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};        // Write your main here    }   }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

I asked this once before but it came up incorrect somehow so I'll submit this one again. Write a program in C# named ArrayDemo that stores an array of 10 integers. (Note that the array is created for you and does not need to be changed.)

Until the user enters a sentinel value, allow the user four options:

(1) to view the list in order from the first to last position in the stored array

(2) to view the list in order from the last to first position

(3) to choose a specific position to view

(4) to quit the application.

--------

using System;
using static System.Console;
class ArrayDemo
{
   static void Main()
   {
       int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};
       // Write your main here
   }  
}
1 using System;
2 using static System.Console;
3 class ArrayDemo
4 {
static void Main()
{
int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1};
Console.WriteLine(" 1. to view the list in order from the first to last position in the stored array\n 2. to view the list in order from the last
6
7
8
choose a specific position to view\n 4. to quit the application. \n");
9.
while(true){
Console.WriteLine("Enter your choice from 1 to 4");
int c = Convert.ToInt32(Console.ReadLine());
if(c==1){
Console.WriteLine("Array from the first to last position is : ");
for(int i=0;i<l®;i++)
Console.WriteLine(nums[[i]);
10
11
12
13
14
15
}
else if(c==2){
Console.WriteLine("Array from the last to first position is : ");
for(int i=9;i>=0;i--)
Console.WriteLine(nums[[i]);
16
17
18
19
20
}
else if(c==3){
Console.WriteLine("Enter array position or index to view : ");
int index = Convert.ToInt 32(Console.ReadLine());
Console.WriteLine("Array element at given index is : ");
Console.WriteLine(nums[index]);
21
22
23
24
25
26
}
else if(c==4){
Environment.Exit(0);
}
27
what I had before
28
29
30
}
}
33 }
31
32
34
Transcribed Image Text:1 using System; 2 using static System.Console; 3 class ArrayDemo 4 { static void Main() { int[] nums = {7, 6, 3, 2, 10, 8, 4, 5, 9, 1}; Console.WriteLine(" 1. to view the list in order from the first to last position in the stored array\n 2. to view the list in order from the last 6 7 8 choose a specific position to view\n 4. to quit the application. \n"); 9. while(true){ Console.WriteLine("Enter your choice from 1 to 4"); int c = Convert.ToInt32(Console.ReadLine()); if(c==1){ Console.WriteLine("Array from the first to last position is : "); for(int i=0;i<l®;i++) Console.WriteLine(nums[[i]); 10 11 12 13 14 15 } else if(c==2){ Console.WriteLine("Array from the last to first position is : "); for(int i=9;i>=0;i--) Console.WriteLine(nums[[i]); 16 17 18 19 20 } else if(c==3){ Console.WriteLine("Enter array position or index to view : "); int index = Convert.ToInt 32(Console.ReadLine()); Console.WriteLine("Array element at given index is : "); Console.WriteLine(nums[index]); 21 22 23 24 25 26 } else if(c==4){ Environment.Exit(0); } 27 what I had before 28 29 30 } } 33 } 31 32 34
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT