using System;
using SC = System.Console;
public class NLastLab8
{ //Main Method
public static void Main()
{
int[] myListArray= new int[12];
myListArray[0] = myListArray[1] = 1;
SC.WriteLine("Lab 8 – Your Name\n");
for (int x = 0; x < 12; ++x)
{
SC.Write("Please enter a value for element {0} -->\t", x);
myListArray[x] = Convert.ToInt32(SC.ReadLine());
}
SC.WriteLine(“\n\nThe values entered were: {0}”, myListArray[0]);
what goes here
SC.WriteLine("\nLab 8 has successfully terminated for Your Name");
Loading
Kirtan PatelPosted Oct 24, 2008, 11:36 PM
Variables according to For Loop
like
MyArray[1]= Get Value From User
MyArray[2]= Get Value From User
MyArray[3]= Get Value From User
Happy Coding :-)
Jenni WitzelPosted Oct 24, 2008, 7:56 PM
SC.Write("Please enter a value for element {0} -->\t", x);
myListArray[x] = Convert.ToInt32(SC.ReadLine());
Alex RivenbarkPosted Oct 23, 2008, 11:30 PM
Try this. I was not sure what you needed. I have included a couple of different possibilities (commented below). Next time you post, try to be more specific about the problem (what should the program do?). An aweful lot of programming is understanding the problem. Let me know if you need further help. Thanks. Take care.
using
System;using
SC = System.Console;public
class NLastLab8{
//Main Method public static void Main(){
int[] myListArray = new int[12];myListArray[0] = myListArray[1] = 1;
SC.WriteLine("Lab 8 – Your Name\n"); for (int x = 0; x < 12; ++x){
SC.Write("Please enter a value for element {0} -->\t", x);myListArray[x] =
Convert.ToInt32(SC.ReadLine());}
//I do not know what you are trying to do here. If you are trying to read the last entered //value, the syntax would be as follows: SC.WriteLine("\n\nThe last value entered was: " + myListArray[myListArray.Length - 1]); //This little guy here insures that the Console does not disappear after the output is shown: SC.ReadKey();
//If you want to output every value that the user input, do the following: SC.WriteLine("The values entered were: "); for (int i = myListArray.Length -1; i >= 0; i--){
SC.WriteLine(myListArray[i]);}
//To do the same thing in ascending order: SC.WriteLine("The values entered were: "); for (int i = 0; i < myListArray.Length; i++){
SC.WriteLine(myListArray[i]);}
SC.WriteLine("\nLab 8 has successfully terminated for Your Name"); //Once again, this keeps the Console from dissappearing: SC.ReadKey();}
}