Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rounding float to nearest 1000
//clang 3.8.0 #include <iostream> #include <cmath> using namespace std; int main() { float price; cin >> price; int roundedPrice = int(price); int remainder = roundedPrice % 1000; if (remainder != 0) { roundedPrice = roundedPrice + 1000 - remainder; } cout << "Rounded price is: " << roundedPrice; }
run
|
edit
|
history
|
help
0
C++ out of ref
test
insertion sort
Alloc
ArrayList Example Starter Code 2
Specialization on signed types
Unqualified free functions
Graphs Iteration2 Directed Graphs
Forgetting to check end
Example Node Program