+ 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
12 Réponses
+ 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.
+ 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;
+ 2
@jojo 12*12=144
+ 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;
+ 2
yes sir already solve sir thank you
+ 1
yes i get it thanks i forgot that there is year*=12 thanks @Hasty Rei
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
0
but this input cant run
- 1
I don't understand what you want to do..
- 1
That's what I understand too
- 1
Woops! Sorry, you're absolutely right...
- 2
Why don't you multiply by 144 (12*12)?