How to roundup a number in C language? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 3

How to roundup a number in C language?

For example : converting 3.7 into 4, 11.4 into 12.

17th Jul 2021, 8:57 AM
Lokesh Soni
Lokesh Soni - avatar
3 Respostas
+ 5
Please do search on the forum or any other services like google, bing, etc before posting a question. https://www.tutorialspoint.com/c_standard_library/c_function_ceil.htm
17th Jul 2021, 9:06 AM
Steve Sajeev
Steve Sajeev - avatar
+ 2
Lokesh Soni Here's a possible solution: int num = (int) x + ((int) x < x) # Hope this helps
17th Jul 2021, 8:41 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
n = (int)n + ((n - (int)n)?1:0);
17th Jul 2021, 10:36 AM
ļ½ļ½‚ļ½ˆļ½‰ļ½Žļ½ļ½–
ļ½ļ½‚ļ½ˆļ½‰ļ½Žļ½ļ½– - avatar