0
using System;


namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("hi..! :)");
        Console.WriteLine("Welcome to 1st program of console by ali which is marksheet...:P ;)");
        Console.WriteLine("Enter the marks of subjects..");

        Int32[] array = new int[5];

        Console.WriteLine("Enter the marks of Maths..!");
        array[0] = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter the marks of Arabic..!");
        array[1] = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter the marks of English..!");
        array[2] = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter the marks of Science..!");
        array[3] = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter the marks of Physics..!");
        array[4] = Convert.ToInt32(Console.ReadLine());

        for(Int32 i=0 i < array.Length i++)
        {
            Console.WriteLine(i + " is the obtained marks from 500..");
        }

        Console.ReadKey();
    }
}

}

4

1 に答える 1

1

for ループを次のように変更します。

for(Int32 i=0 i < array.Length i++)
{
    Console.WriteLine(i + " is the obtained marks from 500..");
}

に:

for(Int32 i=0; i < array.Length; i++)
{
    Console.WriteLine(array[i].ToString() + " is the obtained marks from 500..");
}

また、どの言語でも変数名として「配列」を使用することは、一般的には良い習慣ではありません。配列変数名を myArray や my_array のような名前に変更したい場合があります。

于 2015-02-18T21:06:06.093 に答える