input of cin multiply by the value of ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

input of cin multiply by the value of ?

I have a quest guys . how can i code the input of cin multiply by 12 lets say for example : int year; cin >> year; cout << year *12 << endl; i want the input value of cin will multiply by 12 then / the output will be multiply by 12

11th Jul 2017, 11:07 AM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
12 Answers
+ 8
You can do something like: cin >> year; cout << year * 12 << endl; cout << (year * 12) * 360 << endl; cout << (year * 12) * 360 * 8000 << endl; but I still don't know if this is what you want.
11th Jul 2017, 1:08 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
From what I can make out from your question, you want the variable to be multiplied by 12 before output (in which is multiplied by 12 again) ? int year; cin >> year; year *= 12; cout << year * 12;
11th Jul 2017, 11:14 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
@jojo 12*12=144
11th Jul 2017, 11:28 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
when u write cout<<year*=12<<endl; then u r overloading the binary operator. so use the method @hatsy has written.. and one more edit : cin>>year;
11th Jul 2017, 11:37 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
yes sir already solve sir thank you
11th Jul 2017, 1:11 PM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
+ 1
yes i get it thanks i forgot that there is year*=12 thanks @Hasty Rei
11th Jul 2017, 11:17 AM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
0
i want the like this but its not working int year; cin >> year; cout << year *= 12 << endl; cout << year* = 360 << endl; cout << year* = 8000 << endl; multiple output but not same value
11th Jul 2017, 11:34 AM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
0
but this input cant run
11th Jul 2017, 12:15 PM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
- 1
I don't understand what you want to do..
11th Jul 2017, 11:13 AM
Jojo
- 1
That's what I understand too
11th Jul 2017, 11:15 AM
Jojo
- 1
Woops! Sorry, you're absolutely right...
11th Jul 2017, 11:35 AM
Jojo
- 2
Why don't you multiply by 144 (12*12)?
11th Jul 2017, 11:20 AM
Jojo