////////////////////////////////// // // Author : Wyatt Date : 1/1/2000 // Purpose: To ask a user's name and to say hello // Design: Ask Name // Store name // greet user using stored name // // File: Hello.cpp ///////////////////////////////// #include using namespace std; int main ( ) { // Local Data string firstName; //input variable // Get name from user and store cout << "Enter your first name and press return: "; cin >> firstName; // Display message and name cout << "Hi " << firstName << '.' << endl; cout << "We hope you enjoy studying C++ !\n"; return 0; } //====================================================================== //====================================================================== /* File: Hello.c Author : Wyatt Date : 1/1/2000 Purpose: To ask a user's name and to say hello Design: Ask Name Store name greet user using stored name */ #include int main() { /* Local Data */ char firstName[12]; /*input variable*/ /* Enter name */ printf ("Enter your first name and press return: "); scanf ("%s", &firstName); // need address (here could drop &) /* Display message and name */ printf("hello world, %s\n" , firstName); return 0; }