Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rounding float to nearest 1000 (fixed)
//clang 3.8.0 #include <iostream> #include <cmath> using namespace std; int main() { float price; cin >> price; int roundedPrice = int(price); int multiple = 1000; roundedPrice = ((roundedPrice + multiple/2) / multiple) * multiple; cout << "Old price was: " << price << '\n'; cout << "New price is: " << roundedPrice; }
run
|
edit
|
history
|
help
0
10226
Graphs Iteration 2.1 Directed Graphs
C++ Standard Template Library
Pascals Triangle
sort
hw 1 os
pack expansion
BucketSort
test C++ register
cv5_class