C Programming Tutorial – 37 – Absolute Value with abs

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

Comments

G G says:

this doesnt work on linux, any way to make it?

Abdulnaser Sheikh says:

You can just do this
int year1,year2,age;
Instead of
int year1;
int year2;
int age;

ankur patel says:

in your scanf why did you enter &year1 instead of just year(int variable)

Star_ Media says:

awesome

Count Duncan says:

Pow –> You have to punch your computer xD XD XD XD pls 😀

koren gershoni says:

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?

Sabre Mase says:

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?

Merser says:

when i learn how old i am, i cant help but leave a tear

Kevin Verdhi says:

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);

AJay Gupta says:

use *fabs( )* to find absolite value of float data type.

Nichannick says:

what if i want different sqrt , like third sqrt from number 8  is 2 if you know what i mean . How do i specify it ? because by default its always just basic sqrt.

yerrapotu kiran says:

Danke danke Bucky

Alex Shepler says:

he said something weird at 1:29

Lluís Mª Bosch says:

I’ve sqrt(water) my computer and it does not work anymore, please help

ZoRo says:

the command abs is in which library?

Mister Slovenia says:

How does it work?Is there any place where to learn to code for free?Fucking stupid Americans.

a j says:

#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?

LunarFlare says:

Bucky you should check out CodeLite. It’s my preferred C++ editor. It should work for C since they share the same compiler I believe.

Isabelle Ortiz says:

Hi Bucky, since you mentioned that puts and gets are better, why do you still use printf and scanf instead of gets and puts?

Shadow Meth says:

Is abs function some thing like this? :
int abs(int number)
{
return number * (-1);
}

Stamvid says:

Oh wow 0 dislikes on a 50k video, i have never seen that before :O

Osama Gamal says:

sqrt and fabs
if you know what I mean.

Aetricity says:

I actually guessed 12.8 (not the full thing) for the square root, so that’s great.

ganesh vicky says:

#include
#include
#include

int main()
{
printf(“%fn”, 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?

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!