The ceil function returns the smallest integer that is greater than or equal to x (ie: rounds up the nearest integer).
Sample Program:
/*
Write a program to ceil a number using math function of C.*/
#include<stdio.h>
#include<math.h>
main()
{
{
double number, result;
printf("Enter a number to round it up\n");
scanf("%lf",&number);
result = ceil(number);
printf("Original number = %lf\n", number);
printf("Number rounded up = %lf\n", result);
return 0;
}
0 Comments