YTread Logo
YTread Logo

C Programming Tutorial 20 - Intro to Data Types - Part 2

Apr 07, 2024
Hello guys, welcome back to this video. We'll continue our discussion on

data

types

, so if you don't know what it is, watch the video above, and if you watched the video above, let's dive into a classification of

data

types

. you are going to need to know about the arrangements. Now, later in this series, I'll have a video dedicated to arrangements and a couple of videos on how to work with arrangements and all that good stuff, but now I want to give you an

intro

duction because I know that you guys are going to come across a career and not I want you to have to wait until you like the 758 video to know what a matrix is.
c programming tutorial 20   intro to data types   part 2
An array allows you to store more than one thing within a group of whatever. So for example, we can have an int or a, you can name it whatever you want and an array is indicated with these square brackets and inside here we put some number so we can put you like 10 and essentially what this is going to do. is to give us a bunch of things, okay, I can't, I ran out of space there, but each of them can hold an individual value ball, fit them together, this is all cool and might make more sense if we put nets on it.
c programming tutorial 20   intro to data types   part 2

More Interesting Facts About,

c programming tutorial 20 intro to data types part 2...

Brilliant. You could also have an increase of different data types, for example you can have an array of characters and this would look like this, where each of these is an individual character and all of this is born now, there is another data type that every programmer needs . What to know and that is the string all that is a string is a sequence of characters enclosed in double quotes. I'll just give you an example, it makes a lot more sense this is a string each of these is a character 1 2 3 4 5 6 7 8 9 10 11 characters so this is a string with 11 characters and you can literally think of characters chained together in a sequence.
c programming tutorial 20   intro to data types   part 2
How exactly is this string stored in C

programming

? Well, it's actually stored inside a character array, which makes sense because Think about it, we just have a sequence of characters like down here, we could have, you know, space L I ke, etc., so if we make it variable for store something like I like cats, it should be an array of characters, but this. string is a type of string that needs to be terminated and I'm only going to scratch the surface of this because we'll be dedicating tons of videos to strings later, I promise, but at the end of the string you have to put something called a null character that looks like a backslash 0 this is how we write the null character actually the null character is the absence of everything because that is what null and ull mean but to tell C that we want to put the null character we would put a backslash 0 and this is interpreted as a character just like we have the newline character backslash n, which is a character that goes to the next line.
c programming tutorial 20   intro to data types   part 2
Because of this, the array actually has to be one character longer than you would expect, so we end up with something. so where is the string and now I'm going to split the characters that we end up with 1 2 3 4 5 6 7 8 9 10 11 12 we have an array with 12 elements, everything that is inside an array is called array elements which We'll talk more about strings and arrays in the future, I'll just

intro

duce them to you so you have a rough idea. There is another term that you should know and that term is constant. Clair, what do you want? Claire, now there are two definitions. of constants, one is where you create a variable, but it's like a variable that can never change and you probably know them from science class one, oh, you change this, but this stays constant, that's kind of the definition of constant, too there is another definition that is just a value, so if we declare a variable, the number of caps that I have here is a constant.
Think of a constant as something you can write. It's usually pretty clear, but let's go over some examples of different ways you can write. similar constant, for example, you could have this, you can have this and you could have this, these are three different types of constants that are all very similar, but the data type for these are all different, the first one is a character because of the single quotes, the next one is an integer because there are no quotes and then the third is a string because of the double quotes, you generally don't have to worry much about the data types of the constants.
I'm just trying to give you some additional details, for example, in this situation, this is interpreted as an int, but let me give you another example, let's say we do something like float cats equals 98.5. Well, this brings up an interesting point because this constant here is actually a double data type that we don't really have to worry about. It's a lot about that because we assign it to a float, so we get the expected value of cats being a float data type that has the value 98.5, but sometimes you want to be very, very specific and that can arise at some point along the way.
In the future, if that comes up, there are certain things you can do to be very specific on the data type of a constant. If you want to be specific and say this is a float, you can do things like add an F to it now. is a floating constant. I'm going into a little more detail than you need right now, but it's okay if this is something you guys need to know more about, do your research, read some books about it, or ask a question or ask me something. questions, but for now I think I covered the topic well enough, so thanks guys, make sure to subscribe and I'll see you in the next video.

If you have any copyright issue, please Contact