+ 1
Why the count is 5 as if(c>5)....in the following code...pls explain????...I m a very beginner...
#include <stdio.h> enum { kristi,mh}; int main() { int c=1,count=0; do { printf("%d\n",c++); count ++; if(c>5) break ; } while(mh); printf("%d",count); return 0; }
14 Answers
+ 1
Loop breaks then c=6 (6>5) and count =5
+ 1
Igor Kostrikin ...pls explain
+ 1
Ok..got itđ
+ 1
Igor Kostrikin xplain pls
+ 1
Igor Kostrikin ..frm which country u r??
+ 1
Igor Kostrikin ...will u give me ur email_id ...so that I can contact with u...if u hav no problem....??
0
Your condition for break operator c>5. This work then c=6.
initially c=1, count=0
Loop steps(variables increments on each step) :
1. c=2 count=1
2. c=3 count=2
3. c=4 count=3
4. c=5 count=4
5. c=6 count=5 <- at this step break occurs
0
Here we are printing the value of "c" and then incrementing the value of variable "c"
Simultaneously we incrementing the count value by "1". After that we are checking the value of "c" >5 or not using if condition
0
Why you use internal if operator for loop break? This can be done with correct while(condition)
0
do
{
printf("%d\n",c++);
count++;
} while(c<6)
0
If you use ++c instead of c++ in printf you will see correct values of variable c on each step
0
Russia
0
gosh.tk@yandex.ru
0
C=1 and count =0 initially
Loop will be stopped when c=6 and by that tym count equals to 5