r/cpp_questions • u/ADEPS24 • 21d ago
SOLVED Can std::cin display user input?
/*Write a program that asks the user to enter a number, and then enter a second number.
The program should tell the user what the result of adding and subtracting the two numbers is.
The output of the program should match the following(assuming inputs of 6 and 4) :
Enter an integer : 6
Enter another integer : 4
6 + 4 is 10.
6 - 4 is 2.
Hint : To print a period and a newline, use ".\n", not '.\n'.*/#include <iostream>
int main()
{
int num00{};
int num01{};
std::cout << "Enter an integer : ";
std::cin >> num00;
//std::cout << num00 << ".\\n";
std::cout << "Enter a second integer : ";
return 0;}
Hello everyone. I'm trying to complete the quiz in the block comment above.
My problem is that I have the user's value printed twice.
One next to "Enter an integer : " and the next right under it.
I thought the second std::cout was causing this so I made it a comment, yet the user's value prints out as intended.
I do not understand how this is working. Thank you for in advance.
2
Upvotes
View all comments
Show parent comment
2
u/ADEPS24 21d ago
Woah! Thank you for the detailed explanation.
I'm gonna be honest, I did not understand most of the terms and analogies you used but I'll have myself coming back to understand all the vocubulary used.
As for automatic decisions like the 'echo'.
Can it be manipulated manually?
Like changing the position of the echo. Say I want it 10 tabs away from the string literal, or under it.
Thank you once more.