Please help me with the task: One more calculator

Hello, I’m working on this task:

Write a program that reads an integer count and a double number from the console. Then print the double number count times to the console, adding 1 to the number each time it prints. For example:
>3
>7.926
7.926
8.926
9.926

Here is my code:


namespace DoubleType
{
   class DoubleInLoops
   {
       static void Main(string[] args)
       {
           int count = int.Parse(Console.ReadLine());
           double number = double.Parse(Console.ReadLine());
           Console.ReadLine(number);
           
           for(int i = 0; i < count; i = i++)
           {
               Console.WriteLine(number);
               number = number + 1;
           }
       }
   }
}

Can anyone please help me to solve it?

You have a redundant “Console.ReadLine()” right before the for loop. I think you should remove it.
Otherwise, the logic looks good, except for the i = i++ part. It should be “i++”. The assignment is included in i++:
i++ <–same as → i = i + 1

Thank you. I understood and corrected two mistakes, but still something is wrong.

{

        int count = int.Parse(Console.ReadLine());

        double number = double.Parse(Console.ReadLine());

   

        for(int i = 0; i < count; i++)

        {

            Console.WriteLine(number);

            double number = number + 1;

        }

    }

the initial version of this line was correct, while this one is wrong. You’re trying to initiate a variable again instead of just reassigning it.

1 Like

Thank you so much!!! :))