while condition in do while loop

Status
Not open for further replies.

furqankaimkhani

Member level 4
Joined
Sep 10, 2010
Messages
79
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,946
Can someone pls make me understand this:

Code:
do{
        printf("enter temperature for day %d: ",day);
        scanf("%f",&temper[day]);
        }
        while(temper[day++]>0);

What i need to understand is the sequence in which this while condition will work here.
When will the post increment ++ be executed?

Correct me if i am wrong in it: First, the body of the loop is run once, and then the value (that element in temper array, whose subscript is day), is checked. If that element is greater than 0, then the value of day is incremented and then the body of the loop is again run. And so on...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…