Program To The Following Function TRUNC( ) And ROUND( )
/* Program To The Following Function TRUNC() Which Receives A REAL VALUE AND RETURNS INTEGER VALUE AFTER TRUNCATING THE FRACTIONAL PART, ROUND() WHICH RECEIVES A REAL VALUE AND RETURNS INTEGER VALUE AFTER ROUNDING FRACTIONAL PART */ #include
#include
void main() { int x,y,n; float m; int trunc(float); int round(float); clrscr(); scanf("%f",&m); x=trunc(m); y=round(m); printf(" truncated value is %d",x); printf(" roundedvalue is %d",y); getch(); } int trunc(float m) { int x; x=n; return(x); } int round(float m) { int j,y; j=m; j=m-j; if( j>=0.5 ) y=j+1; return(y); } getch();
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/