This round() is not under math.h header. How to make it work?
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float i=5.4;
printf("%f\t%f",i,round(i));
getch();
}
This round() is not under math.h header. How to make it work?
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float i=5.4;
printf("%f\t%f",i,round(i));
getch();
}
It's not available. You need to write you own using floor
and ceil
.
But better yet, get an up-to-date compiler. There's no excuse to be still using Turbo C++, and the language and libraries have changed incredibly since 1993.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float f=5.4;
int rounded,k;
k=f//Initialising the value of k as the integral value of f
if((f-k)>=0.5)
{
rounded = k+1;
}
else
{
rounded = k;
}
printf("The rounded value is %d",rounded);
getch();
}