-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoreUserInputDEMO.cpp
More file actions
55 lines (44 loc) · 1.59 KB
/
Copy pathMoreUserInputDEMO.cpp
File metadata and controls
55 lines (44 loc) · 1.59 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//************************************************************************
// Author: Rolando Carreon
// Date: jan 28 2025
// Language: C++
// Assignment: Demo
// Description: Hello World Program
//************************************************************************
#include<iostream>
using namespace std;
int main()
{
// declare local variables //
// user input string-firstName, lastName, and phonenumber //
string firstName, lastName;
// WHY is the names on one string but only number on their own string
string phoneNumber;
// single charcter variable //
char myChar;
// output prompt //
cout << "Demo of cin features\n\n";
// display what information you need from the user //
cout << "Please enter your first name: ";
// user input string-firstName //
cin >> firstName;
cout << "Please enter your last name: ";
cin >> lastName;
// user input string-lastName //
cout << "Please enter your phone number: ";
// user input string-phoneNumber //
cin >> phoneNumber;
// display the users input information //
cout << "First Name: " << firstName << endl;
cout << "Last Name: " << lastName << endl;
cout << "Phone Number: " << phoneNumber << endl;
// clear the newline character from the input stream //
// needed to ingnore the enter input used after inputting number //
cin.ignore();
// get a charcter from the user //
cout << "Enter a character: ";
// any button pressed is saved and cout //
myChar = cin.get();
cout << "You pressed " << myChar << endl;
return 0;
}