Code:#include <iostream> #include <string> using namespace std; int dan (); int main() { //Let's call our function dan (); return 0; } int dan () { string mystr; std::cout << "What's your name? "; getline (cin, mystr); if (mystr == "dan"/*String literals come in quotes"*/) cout << "My name is" << mystr << "too"; std::cout << "Hello " << mystr << ".\n"; std::cout << "What is your favorite team? "; getline (cin, mystr); std::cout << "I like " << mystr << " too!" "\n" << std::endl; std::cout << "My name is Dan and i'm starting using C++!" "\n" << std::endl; std::cout << "Look forward to see more Programming from me :D." "\n" << std::endl; //No need to return int if you don't need it //You can make the function to be void dan () return 0; }




Reply With Quote