summaryrefslogtreecommitdiffstats
path: root/src/chapter1/lesson5/cin.cpp
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.cc>2026-08-24 00:48:14 +0300
committerhybrid <hybrid@hybridlabs.cc>2026-08-24 00:48:14 +0300
commite61e04619d0c9dd4d079532eff3483e234fc8acd (patch)
tree561347af88801489977312f4cfd9b33eae75975e /src/chapter1/lesson5/cin.cpp
parentafd71cacbf324b2898220437c10b4db4228b70ce (diff)
downloadlearncpp-e61e04619d0c9dd4d079532eff3483e234fc8acd.tar.gz
learncpp-e61e04619d0c9dd4d079532eff3483e234fc8acd.tar.bz2
learncpp-e61e04619d0c9dd4d079532eff3483e234fc8acd.zip
add: lesson{5,6}, CMakeLists.txt
Diffstat (limited to '')
-rw-r--r--src/chapter1/lesson5/cin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/chapter1/lesson5/cin.cpp b/src/chapter1/lesson5/cin.cpp
new file mode 100644
index 0000000..0fc25f8
--- /dev/null
+++ b/src/chapter1/lesson5/cin.cpp
@@ -0,0 +1,12 @@
+#include <iostream> // for std::cout and std::cin
+
+int main()
+{
+ std::cout << "Enter a number: "; // ask user for a number
+
+ int x{}; // define variable x to hold user input (and value-initialize it)
+ std::cin >> x; // get number from keyboard and store it in variable x
+
+ std::cout << "You entered " << x << '\n';
+ return 0;
+}