Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
List comprehension in C++ using functional patterns
ternary test
10 naturalnumbers
HTML Timetable generator.cpp
Segment Tree Impl
template specialization inheritance solution
Enum flags operator example
Check if a year is leap year or not
Template arguments may contain calls to constexpr functions.
overloading
Please log in to post a comment.