Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All righty, so in this video, what I would like us to do is simply to understand how we should create
a constant in our C programming language now that we've been introduced with what basically the general
idea behind concept.
And now let us talk how they can be used in C.
So there are a couple of definitions that you can use, but the default definition is simply by adding
the word const before the variable declaration.
So, for example, if we know that our year of birth should remain the same during the execution of
the program, then it makes sense to create some variable and to define it as const right.
Because we don't want this variable, this value that we will give to change over time.
Right.
Because the year of birth probably he doesn't make any sense that it will get changed.
So in this case, what you would like to do is simply do the following.
OK, so we use const int year equals to do thousand.
So very, very simple to the way we created our standard variable.
Just just like you, you've created your standard variable, just that.
Now you simply add the keyword const before.
OK, so const integer equals to two thousand.
It doesn't have to be of an integer type.
OK, these kind of values may also a constant valued may also be of a floating point.
I for example like this const float salary equals to thirty one point thirty five.
OK, that's also OK and basically very similar to how you create a variable.
OK, we are talking now about the syntax of constants and see how we create these constants.
So simply adding the cons, the word before and now any attempt that may be used to change this value
will result in a compilation error.
So basically, that's kind of OK, because these compilation error is kind of nice, because if you
will attempt to change its value, it will not be like a problem during the execution.
You will get notified at the compilation step.
OK, so if you will attempt to I don't know if you have, like, I don't know, on a constant salary
per hour, it does not suppose to get changed.
Is also your year of birth.
It's not supposed to get changed during the execution of your program.
So if you simply would have tried to change this value during ah during some, I don't know, function
or whatever calculation you've made by mistake.
Right.
You even you didn't even notice.
So then the compiler will tell you, hey guy, listen, there is a problem, please check it out once
again, the constant value that you are trying to change.
So basically that's how it works.
All right.
So to summarize, you get only one chance to set its value of a constant at the initialization phase
in this case, after words you are not allowed to modify during the execution of your program.
And I hope that's clear because it's not so difficult topic in my opinion.
But some people find it like hard to grasp, especially with information I'm going to share with you
on my next video.
So stay tuned and we will cover everything up really quickly.
So, yeah, I think we are ready to move on.
Thank you for watching.
My name is what we sell for Tech and we are moving forward.
Let me know, of course, if you have any questions and do them by my.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.