-
-
Save itsjohncs/6864491 to your computer and use it in GitHub Desktop.
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
Twix | |
Fido | |
John | |
Smith | |
47 |
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
Skittles | |
Hammy | |
Daniel | |
de Haas | |
20 |
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
Starburst Starla Sarah Fredrickson 82 |
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
// Including iostream for access to cout, cin, and string | |
#include <iostream> | |
// Clarifying which namespace to get cout, cin, and string from. | |
using namespace std; | |
int main() { | |
// Variables are uninitialized because we will get initial input from user. | |
string faveCandy; | |
string firstPet; | |
string firstName; | |
string lastName; | |
int age; | |
// Question: what are the values of the above variables? | |
// User prompts for initializing variables | |
// Notice how they are in blocks that make them logically distinguishable. | |
cout << "Enter your favorite candy: "; | |
cin >> faveCandy; | |
cout << "Enter the name of your first pet: "; | |
cin >> firstPet; | |
cout << "Enter your first and last name: "; | |
// Similar to cout, cin can be chained together to read in multiple inputs | |
// at once. | |
cin >> firstName >> lastName; | |
cout << "Enter your age: "; | |
cin >> age; | |
// Display entered information to user in interesting way. | |
cout << endl; | |
cout << "Your name is " << firstName << " " << lastName | |
<< " and your first pet's name was " << firstPet | |
<< " and your favorite candy is " << faveCandy << " and you are " | |
<< age << " years old." << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment