Created
October 22, 2012 07:05
-
-
Save itsjohncs/3930058 to your computer and use it in GitHub Desktop.
SI Classroom Session 4 - Converting While Loops into For Loops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
string name; | |
cout << "Please enter your first name: "; | |
cin >> name; | |
int i = 0; | |
while (i < name.size()) { | |
cout << name.at(i) << endl; | |
++i; | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
string name; | |
cout << "Please enter your first name: "; | |
cin >> name; | |
for (int i = 0; i < name.size(); ++i) { | |
cout << name.at(i) << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment