arduino abs
Because you’re going to allow the user to answer to values such as May they’re calculating their age. Well, what if they put the year that they were born first like 1986, and they said, try to subtract the current year from it like 2014? Well, if they did that, then it’s going to give you a negative number, because you’re subtracting a bigger number from a smaller one and of course their age wouldn’t be negative 28. So you need to convert that to a positive number. So your program doesn’t crash so again, it’s good for distances and weights and ages. So I’ll show you guys how to build a simple program like that right now, so we’ll go ahead and put into year 1 and int year 2, which is pretty much going to be the two years that they enter to calculate the age of something and we’re Store the final age right there now for printf let’s just go ahead and give them a nice little prompt on the screen be like enter a year now enter a tear. You have to be crying to use this program. All right enter a year, newline and we’ll. Just scanf and for this, of course, for scanning percent D, since we love weird with integers and ampersand year and tyr year, one all right so now, whatever value they entered, hopefully it was an integer. We store it in year, one of course we need to do this again enter another year and store that in year.
Two, so now we got two numbers integers. So the first thing we need to do is make an equation to calculate the age. So H equals year 1 minus year 2. Now this actually doesn’t matter since we’re going to be using absolute value, you can put your two minus two one. You know it won’t make a difference, cool little thing about this. So what I want to do after this is actually print out the value that we came up with first, the value or the original value that we calculated without using absolute value so for now percent the new line and age. Now, after this, what we’re going to do is we’re, going to figure that this number that we came up with can either be the correct one if they entered armed, you know one of the numbers first or the wrong one. It can be negative if they enter the smaller number first, so no matter what we want to go ahead and calculate the absolute value using the function, a be s. So, whenever we pass age into here, if it’s a negative number is going to convert it, convert it into the positive number. If it’s positive is just going to leave it the same so now when you print that bad boy out again check it out, enter your year, 1986 enter another year, 2014, okay, so this one they tried to subtract 2014 from 1986 and it got negative 28.
Well, you don’t want to put that into your program, or else it’s going to crash everything later on. So the absolute value converts that to 28 and of course, if they entered it correctly, which is 2014 1986, it calculates 28 and leaves it at 28. So again, whenever you’re developing software, you always want to assume that the user is going to F something up and you want to make your program is user proof as possible. So using absolute value is a great way to do that sometimes it’s necessary whenever you’re using distances like. If I was to put two distances in there, then either way would be the correct way for the user. So you would still need to use absolute value, same thing with weights and so on and so forth, so um for now, that’s – probably good for this tutorial. Thank you guys for watching actually might as well show you guys some other small ones. Real quick and uh let’s see what I can do go ahead and do this so we’ll just use one print statement and we’ll print out a couple floats and I don’t need to make a whole tutorial for these um. The first one is this function POW. Now this means is, whenever you run this, you have to punch your computer as hard as you can until your fist goes. Pow I’m just kidding actually stands for power, and you need to enter two values for this.
The first one is the base and the second one is the exponent. What this is pretty much saying is: I want to see 5 to the third power. So if you guys don’t know what this is, it should be 125, so pretty much 5 times. 5 is 25 times, 5 is 125, so that’s. What that does again, I don’t need a whole tutorial explaining that and the only other one I wanted mention. Real quick is SQ RT. This stands for squirt and you have to squirt water on your computer. Just kind of good, so this actually stands for square root and whatever number you pass in like 164, it prints the square root of that number. So before I run this, can you guess what it is square root of 164? Probably, on a twelve point, six or something twelve point – eight I was close, but basically the square root of 164 is twelve point. Eight, maybe you guys gets closer than me. So those are a few math functions again out of all of those you’re, probably going to be using absolute value the most, but now you have the power function and square root on hand so well for now.
arduino abs Video
arduino abs news

Posted on Wednesday September 11, 2019
Optical lace for synthetic afferent neural networks ScienceWhereas vision dominates sensing in robots, animals with limited vision deftly navigate their environment using other forms of perception, such as touch. … Continue Reading » 
Posted on Sunday February 17, 2019
AntiLock Brakes For Bike Might Make Rides A Little Safer HackadayCrashing one’s bike is a childhood rite of passage, one that can teach valuable lessons in applied physics. Assuming the kid is properly protected and the crash … … Continue Reading » 
Posted on Tuesday July 23, 2019
I Love The Smell Of ABS Plastic In The Morning HackadayOne lesson we can learn from the Vietnam War documentary Apocalypse Now is that only crazy people like terrible smells just for fun. Surely Lt. Col. Kilgore … … Continue Reading »
arduino abs Social
https://www.pinterest.com/pin/35465915794474667/
https://www.pinterest.com/pin/35465915794474666/
https://www.pinterest.com/pin/35465915794474664/
when i learn how old i am, i cant help but leave a tear
How old are you
gurl thas none of yo bidness
PLease?
@Unknown Account PLease shut UP 🙂
You are 98, I make pretty good assumptions.
Hi Bucky, since you mentioned that puts and gets are better, why do you still use printf and scanf instead of gets and puts?
+Isabelle Ortiz Hi. I’m just learning C programming, but according to my understanding, puts and gets are meant for printing/scanning chars or strings only… in this tutorial, we use integers (numbers). In printf/scanf, we define the variable type after “%” and therefore we can use different ones, than just chars or strings…
You can just do this
int year1,year2,age;
Instead of
int year1;
int year2;
int age;
Gets and puts are very unsafe functions because they lead to buffer overflow and are not used anymore.You can use other function in their place like fgets gets_s etc
scanf is unsafe aswell
@Gordon Matthew It’s Safe compared to Gets
I actually guessed 12.8 (not the full thing) for the square root, so that’s great.
Or u could just use
int age1 = year1 – year2
int age2 = year2 – year1
if(year1>year2){
printf(“%d \n , age1);
}else{
printf(“%d \n, age2);
You could, but don’t you think _abs_ has certain advantages?
int age = abs(year1 – year2);
printf(“%d”, age);
Very untrue, the person reviewing your code will look down on you for it
oh hey,an alive person
*wanna pley my gaem?*
No.. wtf.. 2 years later but still, no.
#include
$$#include
#include
int main()
{
printf(“%f\n”, pow(64,1/3));
return 0;
}
The result of the above program is always 1. But here im trying to find the cubic root of 64
can anyone help me out?
I don’t think that you can put a number to the power of 1/3
make sure u have decimals and make it consistent e.g. pow(64.0,(1.0/3.0)). if the result is going to have decimals u need to have at least 1 d.p. e.g. 1/3 would give 0.333 so u should type 1.0/3.0 or with more decimals instead of 1/3. since datatype was set as float, the computer refused to compute with integers. Also it’s a good practice to predefine the datatype as if not done the computer will guess it for you (probably why ur code didn’t work) e.g. float a=64; float b=1; float c=3; in this way you don’t need to type the decimals.
lmao
Danke danke Bucky
You can just do this
int year1,year2,age;
Instead of
int year1;
int year2;
int age;
You can just do this
int year1,year2,age;
Instead of
int year1;
int year2;
int age;
It looks better 😀
int diceRoll1, diceRoll2, diceRoll3;
int firstSum, SecondSum;
char guess;
diceRoll1 = ( rand()%6 ) + 1;
diceRoll2 = ( rand()%6 ) + 1;
diceRoll3 = ( rand()%6 ) + 1;
firstSum = diceRoll1 + diceRoll2 + diceRoll3;
printf(“First sum of dices: %d \n”, firstSum);
puts(“do you think the next sum will be lower/same/higher? (L,S,H)”);
scanf(” %c”, &guess);
diceRoll1 = ( rand()%6 ) + 1;
diceRoll2 = ( rand()%6 ) + 1;
diceRoll3 = ( rand()%6 ) + 1;
SecondSum = diceRoll1 + diceRoll2 + diceRoll3;
printf(“second sum of dices: %d \n”, SecondSum);
if(guess == ‘L’ && firstSum > SecondSum) puts(“Your rock!”);
else if(guess == ‘S’ && firstSum == SecondSum) puts(“Your Rock!”);
else if(guess == ‘H’ && firstSum < SecondSum) puts("Your rock!"); else printf("Your Sucks!"); return 0; how is that?
the command abs is in which library?
#include
$$The abs function is actually declared in the header.
math.h
#include
$$#include
#include
#include
#include
int main()
{
int age= 333;
printf(” %d”, &age);
age=abs(age);
printf(” %d”, age);
return 0;
}
can you tell me why I have 2686748 333 ?
%d should match with & age right?
You used printf instead of scanf.
Unsigned types can’t store negative values.
this doesnt work on linux, any way to make it?
What is it that doesn’t work? Do you get an error message?
Oh wow 0 dislikes on a 50k video, i have never seen that before :O
well, thanks to you m8, now the vid has one dislike. nice job, a**hole
266:1 is still a very nice rating
yeah, thats like, 532:2
Update: It’s now at 3
Is abs function some thing like this? :
int abs(int number)
{
return number * (1);
}
Shadow Meth No, because by this logic it will convert a positive number into a negative after absolute function…….eg: if number = 4 , then return would be 4*(1) i.e. abs(4) = 4 which is completely wrong,,I guess
awesome
So when I enter this the way you have it shown here. I get errors saying “variable year1, (and year2 and age) are not initialized. I can easily fix it by making year1, year2 & age = 0 but why do i have to do that?
use *fabs( )* to find absolite value of float data type.
sqrt and fabs
if you know what I mean.
he said something weird at 1:29
I’ve sqrt(water) my computer and it does not work anymore, please help
How does it work?Is there any place where to learn to code for free?Fucking stupid Americans.