Hi i’m new in c# programming i’m doing an activity that Will Enter How many inputs and it will view the inserted numbers . Now i only have one problem how can i view only the last inserted number here’s my code:
Console.Write("Enter How Many Inputs: ");
int num1 = int.Parse(Console.ReadLine());
int[] arr = new int[num1];
for (int i = 0; i < num1; i++) {
Console.Write("Input Value #" + (i + 1) + ":");
arr[i] = int.Parse(Console.ReadLine());
}
Console.Write("The Numbers inserted are: ");
for (int x = 0; x < arr.Length; x++) {
Console.Write(" " + arr[x]);
}
Console.Write("The Last Number Inserted is: ");
(???)
Sample Output:
Enter How Many Inputs: 3
Value #1: 80
Value #2: 83
Value #3: 50
The Numbers inserted are: 80 83 50
The Last Number inserted is: 50
I don’t have idea what looping will i use to view the last inserted number.Thank you!
Or