I am trying to print numbers from i to n text file.
I am using Do While loop here. so when i say condition is i < n it is printing i to n number in the text file.
when i say condition is i = n it is printing i number in the text file.
what is the wrong in my program. Please help me.
When I get confused, I say it out in English… “Loop while i is less than or equal to n”
so condition can be i <= n
Also, I should point out that you can use Enumerable.Repeat to create a list of numbers if you want to without a loop.
String.Join(Environment.Newline, Enumerable.Repeat(1,n))
and that can go directly in the Append Line activity or in an Assign
Regards.
The do
statement executes a statement or a block of statements while a specified Boolean expression evaluates to true
. Because that expression is evaluated after each execution of the loop, a do-while
loop executes one or more times. This differs from the while loop, which executes zero or more times.
The do
statement runs at least once irrespective of the condition.
So when you set the condition as i = n
the do
statement is executed once and it writes the current value of i
in the text file and since i <> n
the execution stops.
hello @ramyat
whwnever you set condition i=n its assign value i with value of n
condition should be i<=n like this
so loop match its condition and exit from the loop
hope it help.please mark as solution this answer if it help you
thanks
Thank you>
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.