-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This program is used to learn how to use the getline
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//The use of the getline: | ||
#include <iostream> | ||
int main() | ||
{ | ||
using namespace std; | ||
char ch1[10],ch2[5]; | ||
char ch; | ||
int a; | ||
cout << "What is your first name?"; | ||
cin.getline(ch1, 10); //getline to "Enter" as a symbol of the end of the input | ||
cout << endl<<"What is your last name?"; | ||
cin.getline(ch2, 5); | ||
cout << endl << "What letter grade do you deserve?"; | ||
cin >> ch; | ||
cin.get(); | ||
cout << endl << "What is your age?"; | ||
cin >> a; | ||
cin.get(); | ||
cout << endl << "Name:" << ch1 <<" "<< ch2<<endl; | ||
cout << "Grade:" << char(ch + 1)<<endl; | ||
cout << "Age:" << a; | ||
cin.get(); | ||
return 0; | ||
} |