need help explaining this code
I'm reading my c++ book and i have come across this code that im not quite sure as to what some parts mean and the book doesnt describe them.
1. What does the first "for loop" mean?
i know the basics of the for statement and i know what it does because the book shows me, but i wouldnt know how to re-write that into my own program because i dont know what the specific parts stand for.
2. What is the significance of the second "for loop"?
Isn't it the same as the first "for loop"
Here is the code
Code:
#include <iostream>
#include <string>
int main ()
{
using namespace std;
int counter = 1;
string response;
cout << "Shoul i start counting? ";
cin>> response;
for (int i = 0; i < response.length(); i++) {
response[i] = toupper (response[i];
}
while (response == "YES") {
cout << "counter is " << counter << endl;
counter++;
cout << "Should i continue? ";
cin >> response;
for (int i = 0; i < response.length(); i++) {
response[i] = toupper (response[i];
}
}
cout << "Thanks for counting with me!";
return 0;
}