Тёмный

C Programming Tutorial - 7 - Variables 

thenewboston
Подписаться 2,7 млн
Просмотров 511 тыс.
50% 1

Source Code: github.com/thenewboston-devel...
Core Deployment Guide (AWS): docs.google.com/document/d/16...

Опубликовано:

 

3 авг 2014

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 255   
@idamooooo
@idamooooo 9 лет назад
To conserve space. Instead of typing: int age; int currentYear; int birthYear; I just type: int age, currentYear, birthYear; I've learnt so much after just 1hr+, man! You're absolutely brilliant!
@juliancolearroyo5686
@juliancolearroyo5686 6 лет назад
Idam Obiahu theres an Error when I use int age; int currentYear; int birthYear; Idk why... int age, currentYear, birthYear; This works
@NeilRoy
@NeilRoy 3 года назад
That won't conserve space. It will only take up one line instead of three in your source code, but once the computer compiles your code, it will take up the same amount of space no matter which way you do it.
@omop5922
@omop5922 3 года назад
@@juliancolearroyo5686 stings should be in a single line
@abocwsg2328
@abocwsg2328 Год назад
@@NeilRoy he meant it conserves space in the program
@NeilRoy
@NeilRoy 5 лет назад
A variables is a way for you to store values into computer memory. When you create a variable, you are actually telling the computer you wish to use some of it's memory to store some numbers in (even characters, as each character has a numerical value that gets stored). But, you need to tell the computer how much memory you wish to use, so you set the type, like "int", tells the computer you wish to store an integer, not a floating point (it has no fractional values). All ints on 32bit computers are four bytes, so the computer sets aside four bytes of memory to store your number in. You then give that int a label for you to access it. You could literally access the numerical memory address it uses, but that would be harder to remember than an actual word as a label. You then tell it what value you wish to store into that memory location. When you use it later on, the computer will basically look for where that label is in memory, look at that location in RAM, pull the value out and display it on screen (or if it's a character, it pulls the number, then looks up on a table what the letter is that number represents then displays that character). You can actually display the numerical value of a character if you wish. It is IMPORTANT to understand that ALL variables are stored in memory and that the variable name references a memory address where your value is stored. This will become important later on when you learn about something called pointers, which basically point to an address in memory.
@weirdo2830
@weirdo2830 3 года назад
thanks man
@user-hb1gl1fx7y
@user-hb1gl1fx7y Год назад
Well Put
@masrurwarsy101
@masrurwarsy101 8 лет назад
u r the best teacher i ever had.....
@1356890AC
@1356890AC 9 лет назад
thank god we have you, was completely lost in my C class until I started watching these
@aprender7923
@aprender7923 7 лет назад
I love the way he even teaches this very basic stuff. Love you man.
@MrVayga88
@MrVayga88 9 лет назад
Bucky your the man bro. I cannot tell how much I appreciate your tutorials . I would have paid my last and kept my priceless learning treasure far away from the unappreciatives. Thanks again my brother.
@nukami
@nukami 9 лет назад
Tutorial 6: %f stands for float %s stands for string %d stands for double Source:cheat engine.
@emilyzhou8456
@emilyzhou8456 9 лет назад
Borislav Gridnev another good way to remember it is also on your keyboard. s,d,f are all next to each other
@nicholasflores1459
@nicholasflores1459 8 лет назад
+Peterolen %d stands for decimal. You can use %i in C and it'll still print an integer, but %d is more specific because %i can take in a hexadecimal, or octal base integer.
@anilmawji
@anilmawji 7 лет назад
LOL
@anilmawji
@anilmawji 7 лет назад
that was literally exactly what i was thinking
@arcanerstudios
@arcanerstudios 7 лет назад
%c stands for character .
@jaysonmckeownsr9913
@jaysonmckeownsr9913 6 лет назад
Hey man thanks for the vids. Im in programming classes and the book reads like stereo instructions. And every video you have covers all the chapters in the book so thanks for the great vids. You break everything down and make it so much more understandable. Thx again
@TheUglyvideo
@TheUglyvideo 10 лет назад
I have to say thank you Bucky I wish I'd started your tutorials before Uni. You have changed the way I learn.
@mwawd
@mwawd 7 лет назад
How can someone dislike this ????? Such amazing tutorials. Love this so much. I have learnt so much in a few days. You sir are an incredible citizen. God bless your soul.
@volo7
@volo7 6 лет назад
Love this guy's humor in his teaching. Very entertaining to learn
@azmirakhalid6072
@azmirakhalid6072 3 года назад
I love how he makes every coding sounds so easy
@SmackTV360
@SmackTV360 8 лет назад
Really good video's dude. Much appreciated. I'm taking an algorithm and design class and we are using C to write our first program. Scary stuff but this really helps!
@fu2141
@fu2141 9 лет назад
You can declare variables and give them values in the same line too: int currentYear=2015; int birthYear=1992; int age=currentYear-birthYear;
@manga12298
@manga12298 Год назад
int age; int born = 1992; int now = 2022; age = born - now; printf("Your age is %d", age); yo
@shans4167
@shans4167 7 лет назад
Dude, I must say your stuff is amazing!
@bestbuildpc
@bestbuildpc 9 лет назад
If you wanna learn guys u need to follow these steps by steps but try to do some exercise otherwise u won't get it. I love the way u are taking the time because I see some videos where they go really fast. Sometimes I forget semicolons but inmediately I got an error under and I correct it. Really nice program.
@Rafat235
@Rafat235 6 лет назад
so helpful .I start loving c programming because of this you
@greaterthanbut
@greaterthanbut 10 лет назад
Man I love your tutorials, but it seems to me your always hungry? Which in turn makes me hungry.
@MeeshawnMarathe
@MeeshawnMarathe 5 лет назад
Dude, your videos are really cool! Keep it up!
@muhammadrafay4743
@muhammadrafay4743 5 лет назад
I have now become great in programming thanks for helping me out.
@marufal-razi4969
@marufal-razi4969 8 лет назад
thanks bro.. u help me a lot to learn programming language "c" SO much thank u
@vivekiyer6895
@vivekiyer6895 8 лет назад
superb...you are too cool newboston..keep it up
@howto4366
@howto4366 8 лет назад
thank you very much, you are explaining very good and understandable
@jeffemechatron1367
@jeffemechatron1367 8 лет назад
man. you the best. no doubt!
@nickname_5871
@nickname_5871 4 года назад
we are still watching this :) thanks
@yuvigerstein
@yuvigerstein 8 лет назад
Fantastic tutorials, thanks!
@Coinstarcg
@Coinstarcg 7 лет назад
thanks for the easy way you teach
@ewk67
@ewk67 7 лет назад
thanks for making these so entertaining
@nxtarts6843
@nxtarts6843 9 лет назад
1:40 LOL 69 hotgods
@mosessaintfleur9494
@mosessaintfleur9494 9 лет назад
NxtArts lmfao
@gursidaksingh40
@gursidaksingh40 7 лет назад
i didn't notice that lol
@jwhimself1258
@jwhimself1258 7 лет назад
That's what he was thinking about ;)
@YeetusEliteus
@YeetusEliteus 6 лет назад
or however you spell that
@febuary1497
@febuary1497 6 лет назад
( ͡° ͜ʖ ͡°)
@mrgreen6599
@mrgreen6599 7 лет назад
perfect teacher ever ! owww man we born in the same year lol
@BoubacarDiallo-sp6tw
@BoubacarDiallo-sp6tw 9 лет назад
Thanks a lot for the help!
@amrsakr1691
@amrsakr1691 6 лет назад
Thank you very match i loved your videos
@jaydownlink
@jaydownlink 9 лет назад
I, love, MEATBALL! lol Thanks bucky for the tutorials, looking to get the basic of C to help me when I get an arduino.
@Atristiel
@Atristiel 9 лет назад
In C# you can declare an integer and assign value to it on one line. Example, int x = 10; I discovered that C allows you to do the same.
@kayleexxo
@kayleexxo 2 года назад
Through this video, I learnt how to make a basic calculator. Here is the code: #include int main() { int num1; int num2; int sum; int subtract; int multiply; int division; printf("Enter the num1"); scanf("%d", &num1 ); printf("Enter the num2"); scanf("%d", &num2); sum = num1 + num2; printf("the sum of these numbers is %d ", sum); subtract = num1 - num2; printf("the difference of these numbers is %d ", subtract); multiply = num1 * num2; printf("the product of these numbers is %d ", multiply); division = num1 / num2; printf("the division of these numbers is %d ", division); return 0; }
@Xinmin1000
@Xinmin1000 9 лет назад
You are very good teacher although you are really young. Thanks!
@omerkira7535
@omerkira7535 8 лет назад
Your tutorials till now have helped me out as i am starting from scratch in here and i started with your videos a week ago and it's going pretty well, but i have some questions i need an answer for, because i keep practicing and what i figured out that when i put the variables age, current year and birth year while not deleting the first line which is int age alone, it gives me an error till i change age into something else like ege for example then it runs very good, i know how stupid it is but actually i will do anything to learn, thanks in advance :)
@thclanavenger
@thclanavenger 4 года назад
Bucky youre my hero
@heavenlybeing95
@heavenlybeing95 9 лет назад
Great teacher bro :) thx a lot (y)
@jaswaanthbhaskar4158
@jaswaanthbhaskar4158 8 лет назад
wow...cool tutorial and cool tutor ever I've seen...
@HikikomoriDev
@HikikomoriDev 9 лет назад
Yo bucky, thanks ma man!
@drGeppo
@drGeppo 5 лет назад
"I always wandered that, and now I know" LOL
@elghasseimsenghott2707
@elghasseimsenghott2707 7 лет назад
good job well explained
@LeonasMilius
@LeonasMilius 8 лет назад
Thanks for video. Question: int name; name = "Mrs X"; why string has to be declared as int to get it printed? i tried str name; < but it's incorect and we use int to declare string?
@GermanGood2
@GermanGood2 9 лет назад
really awesome thing
@lasun8960
@lasun8960 9 лет назад
Awesomeness
@ayushjha5796
@ayushjha5796 8 лет назад
Age calculator where the user gets to input his current year and birthyear, #include #include int main() { int age; int currentYear; int birthYear; printf("Enter your birthyear"); scanf("%d",&birthYear); printf("Enter your currentyear"); scanf("%d",&currentYear); age = currentYear - birthYear; printf("you are %d years old", age); return 0; }
@sarthakgaba1583
@sarthakgaba1583 5 лет назад
Thanks!
@mohamedwaellabidi1850
@mohamedwaellabidi1850 6 лет назад
Thank you
@trtube87
@trtube87 7 лет назад
u r awesome ,upload more
@nishkarshadawadi2283
@nishkarshadawadi2283 6 лет назад
"I always wondered that, and now I know" hahaha
@khalidhd3248
@khalidhd3248 8 лет назад
thank you
@xkankesx
@xkankesx 8 лет назад
1:31 You can actually start a variable with an underscore. Or at least, I just tried it and it did in fact work.
@YariCodes
@YariCodes 7 лет назад
It is not risky.
@patrolman53
@patrolman53 9 лет назад
Watching this video in 1.5x normal speed.... Ahh that's better :P
@A0pplePapple
@A0pplePapple 6 лет назад
1.25
@shivanngpuri
@shivanngpuri 3 года назад
5:11 "Boom, ShaBang, pretty stinking sweet" LOL
@rohitnautiyal7130
@rohitnautiyal7130 6 лет назад
How can i limit the digits(after decimal point and in general too) of the no. that is to be entered by the user?
@subscribes6434
@subscribes6434 6 лет назад
For Future Use: (IM just writing this as a side note When I return to this video later on. 3:35 explaining what the variable does and the setup
@user-gi3ro9rm9k
@user-gi3ro9rm9k 7 лет назад
'69hotdogs' great choice bucky...
@petrikamilo7129
@petrikamilo7129 6 лет назад
He wrote "69hotgod" lol
@Alpha_zone84
@Alpha_zone84 8 лет назад
never mind the screen is just hard to see with some videos the comma had to go out side of the quotes lol my bad just needed to take a better look
@tommywu6
@tommywu6 9 лет назад
7:29 am Work so hard ~
@hayabusacooper8525
@hayabusacooper8525 9 лет назад
To conserve More space. Instead of typing: int age; int currentYear' int birthYear; currentYear = 2015; birthYear = 1987; age = currentYear - birthYear; i just type: int age, currentyear = 2015, birthyear = 1987; age = currentyear - birthyear; _ C = bucky + thenewboston; Thanks C.! :D
@komekko373
@komekko373 6 лет назад
Hayabusa Cooper That will give you Error...
@OMindsstuff
@OMindsstuff 3 года назад
thank you for this awesome video. Can you provide notes too?
@adsgfsgd
@adsgfsgd 6 лет назад
My professor emphasizes that it is critical we know variable is NOT A PLACEHOLDER but rather a named LOCATION in memory.
@lazygizmo
@lazygizmo 8 лет назад
nice. i was going through the age code with you on my code block try to figure out my age and i noticed you didn't explain why the Year was capitalized. so i tried it with lowercase on the int and the program failed. i guess capital letters with no spaces is the way the computer can differentiate one word from another when not in strings? int currentYear vs printf("current year is blah")
@redfox5305
@redfox5305 3 месяца назад
Takin C 2024
@mr.inconspicuous6395
@mr.inconspicuous6395 7 лет назад
I still dont get all the #include in the beginning. Its suppose to tell the program what things/functions I want to use?
@brankogrbic6877
@brankogrbic6877 7 лет назад
that means that you included library. There are many library types. For example: if you want square root then you type: #include .
@RandyShelton1
@RandyShelton1 7 лет назад
This is done to save space. Imagine you are going on a trip. It would be silly to pack everything you own for the trip, right. You only pack the things you need. C does the same thing, each library you call packs the things that you need for your program. This is done to save memory and speed up a program. When you use C for something that isn't a computer, say a microcontroller, you would run out of space very fast and it would slow down your program. Your compiler might optimize these unused pieces of code out but you can not be sure of that. You can search C libraries online to find what functions are located in each library.
@yerrapotukiran9400
@yerrapotukiran9400 7 лет назад
+Branko Grbic thanks man , could u plz tell me what is "int main( )"
@brankogrbic6877
@brankogrbic6877 7 лет назад
Place where the main code is typing, i think, but I am not sure
@mehmetalidemir8380
@mehmetalidemir8380 7 лет назад
like the ones before me told you, it are librarys which other people already programmed for your usage. so you don't have to teach your program what the mathematical operations "+, -, x, /" means and how they work. It meaks the life much easier and saves a lot of time and storage.
@AndRew-mq8bb
@AndRew-mq8bb 3 года назад
Does anyone knows how to activate the "red box"error symbol afterr compiling code. Mine doesnt have the red box which s inconvenient since i have to go to logs to find error line number. Thx
@breddarz86
@breddarz86 8 лет назад
Is there a way to work out age with the months as well as years? I may be born in 1987 but if it's only July and I'm born in October then I'm not 29 yet.
@lordbumus6087
@lordbumus6087 8 лет назад
float age = 28.blahblahblah
@codeforest9027
@codeforest9027 5 лет назад
maybe you can keep month variable equal to 10 (october) and write an if statement (later tutorials maybe) to see if the birth month is more than the current. If it is true, then year - current else year - current - 1
@saumyatiwari2280
@saumyatiwari2280 8 лет назад
you should zoom whatever you are writing as it is less visible.
@albertoeinstein3936
@albertoeinstein3936 8 лет назад
+Saumya Tiwari Put it on fullscreen and 1080p.
@madmadpussymonster
@madmadpussymonster 9 лет назад
Why do you need both header files? I ask because I realized it still works with just stdio.h
@edmarmac6092
@edmarmac6092 7 лет назад
what is difference %d vs %i please?
@ignabelitzky
@ignabelitzky 7 лет назад
With the function printf both works equal... but when you use the function scanf (for get input information) they work different, the i in %i stands for integer, and the d in %d stands for decimal... PD: Sorry for my english, but I am Argentinian
@kirinma9069
@kirinma9069 8 лет назад
Font is so little .What if it can be adjusted bigger
@MegaDheerajVerma
@MegaDheerajVerma 7 лет назад
what about problem with other contents that hides just bcoz of zooming?
@Jemmeh
@Jemmeh 6 лет назад
Full screen the video and put it in HD. If that's still too small use Windows Magnifier.
@SevenDayGaming
@SevenDayGaming 7 лет назад
Hey, what do I do if it thinks 16+2 is 103 and 20-2 is 87? EDIT: Nevermind. I had the formula before the other two variables.
@lukedavoli2868
@lukedavoli2868 9 лет назад
i love meatball
@jasonheard2436
@jasonheard2436 7 лет назад
// Thank you!
@omop5922
@omop5922 3 года назад
Your comment is underrated for so many years
@dibyendubiswas3937
@dibyendubiswas3937 8 лет назад
why do we use int main in the starting
@Animelover1346
@Animelover1346 8 лет назад
Sooo guys have you heard that Brian knight changed his life when he learnt to code?!?
@timbudongnp
@timbudongnp 6 лет назад
can we replace %d with something like %f or %a?
@reftu1489
@reftu1489 6 лет назад
So how old are you exactly?
@mithrandir965
@mithrandir965 9 лет назад
cant we use decimals in variables?
@omop5922
@omop5922 3 года назад
So did u try in these 5 years
@kelvinluk9121
@kelvinluk9121 8 лет назад
is C case sensitive?
@vinodunnithan1360
@vinodunnithan1360 3 года назад
How is x track. When in play code is b. Ball variable crib c. Decides call 45./https can you open lower case for reverse#_
@nicholaslee6098
@nicholaslee6098 7 лет назад
int main() { char you[4] = "Alex"; printf("My name is %s ", you ); } It prints "My name is AlexD... Even if u change the you, It still prints with "D". Why?
@DreadKyller
@DreadKyller 10 лет назад
Now obviously that program wouldn't actually work to find your age all the time, as that also depends on the month, if you were born in December but it's only August, that program would print out 1 year older than you are, because it doesn't factor in the month/days/etc.
@someshs.m.9969
@someshs.m.9969 6 лет назад
int lgelength, armlength, value, finalresult; leglength=2.5; armlength=3.5; value=leglength/0.2; final result = armlength+value; printf(" height of a person is %d", finalresult); return 0; for the above code the output should be 13. But i am getting 12. if any one know why is this happening please reply to this comment
@naeemghafori5046
@naeemghafori5046 7 лет назад
bucky is now 30 years old
@PunchineloPow
@PunchineloPow 7 лет назад
Can anyone recommend a way of knowing what header files will be useful to me in different given situations? So far I have only had to use .
@SuperSampling
@SuperSampling 7 лет назад
en.cppreference.com/w/c/header
@PunchineloPow
@PunchineloPow 7 лет назад
Thats spot on mate, thanks :D
@furkansungu2286
@furkansungu2286 7 лет назад
when I write 17 it shows as 56 , when I write 15 it shows as 8 :d What's the problem?
@tarkylmaz3750
@tarkylmaz3750 7 лет назад
%d refers to digit and %s refers to string u may wanna say that ^^
@am33x
@am33x 6 лет назад
10 teachers disliked because you're better than them.
@supriyagupta922
@supriyagupta922 6 лет назад
i have written my age 18 nd after compiling its showing me 2 years old.... what can be the reason
@fruckstuck
@fruckstuck 6 лет назад
why do you include #include ? there is no need for that.
@emilia3767
@emilia3767 7 лет назад
Uh. Can someone explain the entire int main() thing in the beginning? and why we have to put return 0; after after the function?
@GamingBlake2002
@GamingBlake2002 7 лет назад
everything in "int main()" is what gets run in the program. "return 0;" exits the program
@emilia3767
@emilia3767 7 лет назад
Blake Abernathy Soo, if type stuff before int main it won't be a part of the program?
@GamingBlake2002
@GamingBlake2002 7 лет назад
I'm not super experienced but I've never seen a C program with anything before the "int main()" (except for including libraries)
@emilia3767
@emilia3767 7 лет назад
Blake Abernathy I see, that makes sense :) Thank youu ~
@GamingBlake2002
@GamingBlake2002 7 лет назад
Your welcome :D
@yingtang9073
@yingtang9073 7 лет назад
why I put "age=currentyear-birthyear;" infront of " birthyear=1917; currentyear=2017;" ,the output is minus 83 years old?
@yingtang9073
@yingtang9073 7 лет назад
I get it now. I guess I have learned a few things these days. :)
@jonusbrothers2067
@jonusbrothers2067 7 лет назад
i am not understanding that why we are using "return 0 "..i mean why 0?? please reply asap.. please help##
@komekko373
@komekko373 6 лет назад
jonus brothers it's One return to the main Function every time you use Code
@kalpthakkar5018
@kalpthakkar5018 7 лет назад
letters are too small to see clearly.can you plz make it bigger?
@calverezrogers8355
@calverezrogers8355 8 лет назад
Bucky hey I was wondering why doesn't code like this out put 20 in the second printf line.Please get around to me or anyone else. #include #include int main () { int age ; age=20 ; printf("This is Joseph's age %d ",age); printf("Joseph is",20,"years old"); return 0; }
@EpicDeception
@EpicDeception 8 лет назад
Because you can't just slap a number like that in the middle! You use the comma only in conjuction with a variable and a conversion character. printf("Joseph is %d years old", age); You also dont really need two newlines but whatever
@KnowledgeIT
@KnowledgeIT 6 лет назад
Why we use #include #include ?
@valerontoscano3047
@valerontoscano3047 6 лет назад
He explained this in his earlier tutorial
@KnowledgeIT
@KnowledgeIT 6 лет назад
Ok, I am waiting for your new lesson.
@nabilfaisal115
@nabilfaisal115 4 года назад
is Bucky 33 by now??
@abirhasnatzawad1135
@abirhasnatzawad1135 6 лет назад
(int age; age=210+100;) the answer is:310 BUT if i write (int age; age=210+0100;) the answer shows:274 Why???????????