0
for(int x=1;x<=10;x++){ //write a code that counts n return the numbers generated by the loop //eg..10 digits generated by this
c++
3 Respostas
+ 6
in your sample code, when loop terminates the value of x will be 11 and the numbers generated by loop will be 10. So simply subtract 1 from the value of x and you will your required output.
Note that you have declared variable x inside a loop so when you use this variable outside the loop it will give error. So you declare your variable outside the loop.
int x;
for (x = 1; x <= 10; x++) {}
cout << "Digits generated by this loop is: " << x-1 << endl;
+ 1
Stv vosti I did not understand your question.
+ 1
thanks..it worked