Round Up to Ten
Programming Basics · C++
TASK
Problem
Given an integer `n`, print the smallest multiple of 10 that is greater than or equal to `n`.
EXAMPLE
Example
1
10
LIMITS
Constraints
0 ≤ n ≤ 10^9.
LEARN
Theory for this problem
+
These exercises combine arithmetic, comparisons, and small branches. Keep each condition explicit and easy to verify.
Connection to “Round Up to Ten”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.
NEED HELP?
Hints
+
['Break the task into a few simple checks instead of compressing everything into a clever expression.', 'After solving “Round Up to Ten”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']
ANSWER
Solution
+
#include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
cout << ((n+9)/10)*10 << '\n';
return 0;
}