-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputExercise.cpp
More file actions
32 lines (26 loc) · 1.14 KB
/
inputExercise.cpp
File metadata and controls
32 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
using namespace std;
int main()
{
string fullName, address, major;
char gender, ch;
cout << "Enter your full name: ";
getline(cin, fullName); //_ _ Mike _ Smith _ _<enter>
cout << "=>" << fullName << "<=" << endl;
cout << "Enter your gender (m or f): ";
cin >> gender; //_ m _ _<enter>
cout << "=>" << gender << "<=" << endl;
// cin.ignore();
// cin.ignore(2, '\n');
// cin.ignore(100, '\n');
cout << "Enter a character: ";
cin.get(ch);
cout << "=>" << ch << "<=" << endl;
cout << "Enter your address: ";
getline(cin, address); //123 1st st, sm, ca<enter>
cout << "=>" << address << "<=" << endl;
cout << "Enter your major: ";
getline(cin, major); //computer science<enter>
cout << "=>" << major << "<=" << endl;
return 0;
}