Each time for loop repeats print different console.WriteLine

235 views Asked by At

Everything runs perfectly. If a user enters more than one to repeat the first for loop I want the question to say "Please enter number 2" and so forth. Is there way to do this within the same Console.WriteLine?

using System;

namespace Looping
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("How many numbers will you provide?");
            int numbersProvide = Convert.ToInt32(Console.ReadLine());

            int i;

            for (i = 0;  i < numbersProvide; i++)
            {
                Console.WriteLine("Please enter number:");
                int enterNum = Convert.ToInt32(Console.ReadLine());

                int j;
                int sum = 0;
          
                double addDiv;

                for (j = 1; j <= 25; j++)
                {
                    if (enterNum % j == 0)
                    {
                       addDiv = enterNum / j;
                       Console.WriteLine(enterNum + " is divisible by " + j + "(" + addDiv + ")");
                        sum += j;
                    }
                }
                Console.WriteLine("The sum of the quotient is: " + sum);
            }
            Console.ReadKey();
        }
    }
}
1

There are 1 answers

0
Hervé On

Just use the index variable i of your loop

Console.WriteLine($"Please enter number {i + 1} :");