How to ROUND Value in C Language

How to ROUND Value in C Language:

(1) In this blog we will see how to Round value in C Language.

(2) In there are two functions which round value. 1. CEIL() and 2. FLOOR().

(3) CEIL(): It is used for round value Upwards.

(4) FLOOR(): It is used for round value Downwards.

(5) For using these function add  “#include <math.h>” library.

(6) Sample C language code and its output, as shown:

Sample ROUND Value code in C
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
float x;
  x = 3.5;
  //Round Amount in upward
printf(“Upward Rounded Amount is %f\n”,ceil(x));
  //Round Amount in downward
printf(“Downward Rounded Amount is %f”,floor(x));
getch();
return 0;
}
}

(7) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

click on build button for continue statement in C

(8) After building the code, press the “Run” button, as shown.

run the ROUND Value in C Language

(9) After pressing the “run” button, the output screen is opened, as shown.

Output for round value in C

Function Declaration in C Language
Create and Use Function with Parameters in C Language
Continue Statement in C Language
Break Statement in C language
ARRAY in C Language
Use of UNION and UNION ALL Operator in SQL
LEN (Transact-SQL)– Microsoft Docs

Leave a Reply