i>N not understood

in the example given what is i and how it is greater than N

Hello @Komal-Mahajan-3119143664812483,

The question is to add first n natural numbers.
i is used as a counter.

i>N is the condition we have used inside the diamond.
That condition will decide whether we will go towards the branch of yes or branch of no.

Suppose we enter N=3 i.e. we want sum of first 3 natural numbers i.e 1, 2, 3

  1. i has an initial value of 1.
    So, i>N ?
    No, because 1<3
    So, we will add i to sum i.e. sum=0+1=1
    Now, we will add 1 to i i.e. i=i+1=1+1=2

  2. for i=2:
    i>N?
    No, because 2<3
    So, we will add i to sum i.e. sum=1+2=3
    Now, we will add 1 to i i.e. i=i+1=2+1=3

  3. for i=3:
    i>N?
    No, because 3=3
    So, we will add i to sum i.e. sum=3+3=6
    Now, we will add 1 to i i.e. i=i+1=3+1=4

  4. for i=4:
    i>N?
    Yes,
    print sum i.e. 6

  5. exit

Hope, this would help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.