0

C++ round integer UP to the next multiple of 10

It's embarrassing but although there are so many related articles out there, I just don't get it. Let's say that I have int numbersSum. If it is 41, I want to get an int of 50 if it is 67 I want to get an int of 70 Only round up to the next multiple of 10 and store that value in an int variable! I tried ceil but it won't do it. Any suggestions? Thanks in advance! 🍺 PS: Rookie here 😊

2nd Dec 2017, 5:30 PM
Dimitris Petrakis
Dimitris Petrakis - avatar
2 Antworten
+ 6
@kurwius Haaaa That's awesome! ok other one #include <stdio.h> #include <math.h> int main(){ printf("%f",ceil(67.0/10)*10); return 0; }
2nd Dec 2017, 5:50 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
worked great! thank you so much, guys! I used your code @Very_Hard ! 😁
2nd Dec 2017, 6:23 PM
Dimitris Petrakis
Dimitris Petrakis - avatar