sir,what is difference between while and for loop?.In terms of
for loop. it outputs one number greater than what we want to output
cout<<x<<endl;}it outputs 0to6 numbers.
yet 0 to 6 numbers are still 7 numbers.further when we change x<7 to x<=7.it ouputs 0 to 7 numbers which is still 8 num.
can you explain me why?
It just counts from the starting point you give it to the ending point you give it. You stated that x should start from 0 and should stay less than 7, so it printed 0 to 6 because all the numbers in this limit meets the specifications you have described. Similarly it did in the second statement you have mentioned. If you want to output 6 digits then you should give first condition to be x=1. Hope you are getting my point.