Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts
Amazon Auto Links: No products found.
i love your videos ,but i don’t like bacon
sorry i have new fix and more easy:
int main()
{
using namespace std;
double n,v,k,m,k1, r;
n = 100,67; //
v = 4.26; //
m = 20; //
k = n – m;
r = k / v;
cout << "NOT Rounded= " << r << endl; cout << "Rounded= " << round ( r )<< endl; system ("pause"); return 0;
how do I can convert this into c++??
Note: Always name a float bacon1
there’s the round() function that rounds the number like we were taught in elementary
if you want it to round as we normally do, then do Floor(number+0.5), and that will round it up if it is .5 or above, or down if it’s .4 or below. You can also do Ciel(number-0.5) but who likes subtraction?
For example: you have 3.5 this would round to 4 right? Well, let’s plug it in. Floor(3.5+0.5) = Floor(4.0) = 4.0.
And for 3.1? Floor(3.1+0.5) = Floor(3.6) = 3.0
how to round up to the nearest 10th?
How come I get a compiler error? I wrote the exact same code as you did.
Yet I keep getting the undefined reference to both floor and ceil.
the most EASY WAYS TO ROUND THE NUMBER IS:
#include
#include
#include
#include
#include
coz, why the heck not ? and @bucky, what happened to the chick ? your friend’s hot friend ?
-1 for forgetting to mention the round() function which also exists in math.h.
-1 for saying that the computer isn’t as smart as smart. as stated by Sebastian, it can round to the nearest whole number. Even if round wasn’t available, you could use floor(float + 0.5) for positive values.
Geez Bucky! Go to bed! You have work in the morning!
There is a round() function in the math.h library that does normal rounding. You don’t have to specify if you want to round up or down.
Thanks!
flour = flout sorry and after 45.8494 is ; =45.8494;
Bucky you are the man
Ceil stands for ceiling, like a roof.
link or video how to round decimal numbers?
Idk how you make coding interesting/funny but you do
I think it works better 🙂
#include
#include
#include
Can someone tell me how to have these #include texts in my programs durable?
Mildlyhomestuck
how about i want to rounding up to nearest 0.5?
for example:
13.14 => 13.50
13.61 => 14.00
13.50 => 13.50
I rounded with floor this: 5.999999999999999999999999. It didn’t rounded down, it actually got me 6! You need at least 7 9’s after decimal place for it to round it up
Bucky why do you use floats instead of doubles?
floor= u know what it is
ceil= plaster of a roof
Actually there is a Another Way to do this just type .0 in between % and f (%.0f) and this will Round the Numbers
Thanks for help me
Hey guys here is my code, but I want to know if there is a command that allows to test the second number after the comma in a number ( ex: 9.6 : test the “6” if it’s above or less than 5 ). that will make it more efficient:
int main()
{
float num1 = 9.4;
if(num1>=9.5){
printf(“num1 is %.2f n”, ceil(num1));
}else{
printf(“num1 is %.2f n”, floor(num1));
}
return 0;
}
just use “% . 1f” this will round up the number to 1 decimal point and it will do it the way we used to do it in classes. THIS IS SIMPLE AND BEST
I still cant debug my problem in greedy(program) of the value 4.2. what am I missing?