February 5, 2011

C Program to Round Up a Number


This program is shared by Krunal Panchal, thanks for your contributions. Feel free to submit your program's to be posted on my c files.

This is a program for rounding up and down float values in c

For e.g if you have got float value of 8.5 then it is converted in to 9 and when you have got float value of 8.4 then it would be converted into 8.
Same way for any float value it could be converted to round up value into an integer.


Code:

//C Program to Round Up a Number
#include<stdio.h>
#include<conio.h>
void main()
{
float n;
int i;
clrscr();
printf("\nEnter the Value\n\n");
scanf("%f",&n);
i=(n<0)?n-0.5:n+0.5;
printf("\nRound up value= %d",i);
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories: ,

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails