+ 1

How to input text in cin... For example... Compiled.. Please enter no. : input... And sum

5th Jun 2018, 10:37 AM
NamVr
NamVr - avatar
6 Antworten
0
Read up on the above post, should give you an overall understanding on that topic... To answer your question. #include <iostream> using namespace std; int a, b; //declare variables int main() { cin >> a; // stores user input in a cin >> b; // stores user input in b cout << a + b; //prints sum of a & b return 0; }
5th Jun 2018, 11:18 AM
Grandad
Grandad - avatar
5th Jun 2018, 10:42 AM
Scooby
Scooby - avatar
0
no i am asking that if we could add a text before aksing for an input in cin
5th Jun 2018, 11:56 AM
NamVr
NamVr - avatar
0
ok thx
9th Jun 2018, 11:41 AM
NamVr
NamVr - avatar
0
Add a text how? As an input to the computer or as an output to the user, you might need to expatiate but yeah definitely both can be accomplished
21st Jun 2018, 9:44 PM
Grandad
Grandad - avatar
0
The correct answer I got is- cout << Enter no; cin >> a; and then futher
9th Nov 2018, 9:11 AM
NamVr
NamVr - avatar