answersLogoWhite

0

Use the round() function in the C99 standard library.

Example:

#include<math.h>

#include<assert.h>

double x = 0.1234567;

assert ((round (x * 10) / 10) == 0.10);

assert ((round (x * 100) / 100) == 0.120);

assert ((round (x * 1000) / 1000) == 0.1230);

assert ((round (x * 10000) / 10000) == 0.12350);

assert ((round (x * 100000) / 100000) == 0.123460);

assert ((round (x * 1000000) / 1000000) == 0.1234570);

assert ((round (x * 10000000) / 10000000) == 0.12345670);

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

What programming language do I use to program Wii games for free?

you cant for free, but i was looking round to find what language games are written in and most are in C/C++


What is the value of C to the nearest tenth?

If you want us to round a number to the nearest tenth, we'll need the number.


What represents valid integer number in c language?

1500


What number is equivalent to -4e3 in c language?

In C, it is -4000.0 In others languages, it is -4000.0


Is 'a' equals ''a'' in c language?

No, the first is a number (0x91), the second is a pointer.


How do you round off a double value in c plus plus?

To round off to the nearest integer... double a = {some value}; a = (int) (a + 0.5); To round off to the nearest hundredth... double a = {some value}; a = (int) (a * 100. + 0.5) / 100.; These are just two examples.


Why c language has name c why not a?

C-language was derived from B-language.


Floating point number in c-language?

any real number e.g, 15.5 1456.223 4568.12


Write a programme for substraction of two numbers in c language?

substracion of any two number program in c


Which language do programmers use if the problem requires a lot of number crunching?

C++


What are some of the top compilers for the C Computer Language currently used in the technology industry?

There are a number of top compilers for the C Computer Language which is currently used in the technology industry. You can try such compilers as C++, C Front and others.


How do you find the smallest largest numbers in c language?

for the largest number: #include&lt;stdio.h&gt; void main() { int a,b,c,number,largestnumber; a=99; b=9; c=77; if(a&gt;b) { number=a; } else if(b&gt;c) { number=b; } else { number=c; } largestnumber=number; printf("%d",largestnumber); }