none
program that ask the user to Enter the number of student and numbers of marks then calculate the average for every student RRS feed

  • Question

  • int sum = 0;
                double avg;
                Console.Write("Enter the Number of Student =");
                int N = int.Parse(Console.ReadLine());
                Console.Write("Enter the Number of Marks =");
                int M = int.Parse(Console.ReadLine());
                for (int I=1;I<=N;I++)
                {
                    for(int Y=1;Y<=M;Y++)
                  {
                      Console.Write("the mark"+Y+"=");
                      int Mark = int.Parse(Console.ReadLine());
                      sum += Mark;
                  }
                    avg = sum / M;
                    Console.WriteLine("the average of the student=" + avg);
                }
                Console.ReadKey();
    Thursday, April 26, 2018 3:38 PM

All replies

  •             double avg;
                Console.Write("Enter the Number of Student =");
                int N = int.Parse(Console.ReadLine());
                Console.Write("Enter the Number of Marks =");
                int M = int.Parse(Console.ReadLine());
                for (int I = 1; I <= N; I++)
                {
                    int sum = 0;
                    for (int Y = 1; Y <= M; Y++)
                    {
                        Console.Write("the mark" + Y + "=");
                        int Mark = int.Parse(Console.ReadLine());
                        sum += Mark;
                    }
                    avg = (double)sum / M;
                    Console.WriteLine("the average of the student=" + avg);
                }
                Console.ReadKey();

    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.
    Thursday, April 26, 2018 3:45 PM
  • Hello omar,

    Is there any update or any other assistance I could provide? You could mark the helpful reply as answer if the issue has been solved. And if you have any concerns, please do not hesitate to let us know.

    Best regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 3, 2018 7:20 AM
    Moderator