Hello everyone.
My name is Atharva and we are continuing with this programming course.
In the last video we learned the basic way to write C programming.
Which means the basic syntaxes of C programming.
In this video we are going to see our variables or those things in which we insert specific values and those values change going ahead in the program.
The data type of these variables, which means what kind of values will be stored in it, who defines those things or who tells it, we are going to know about that thing in this video.
That is the reason we are going to see what are the data types in C programming? What are data types? Now we will take an example.
Like we have taken a container.
Okay.
We took which type of container? In which we make tea.
How will be the container to make the tea? Will it have holes at the bottom? No, the container for making the tea will be completely solid, it will not have any holes.
Because if it has holes, the tea will come out of it and it will never be filled.
In the same way, the vegetables that we get from the market and when we wash them with the water which type of utensil, we keep them in? Do we keep it in a solid utensil? No, we keep them in such a utensil in which there are small holes or pores at the bottom so that the water used to wash those vegetable come out easily and the vegetables get dry.
So, for everything there are different containers that are defined.
In the same way the variables in which we are putting or assigning different values and later we are changing those values.
How will we know that in that particular variable which type of value will come? Like looking form outside we get to know about the utensil, there are no holes in it, so the tea can come in it.
And if this is a utensil with holes, we will say that we must wash the vegetables in it and if it is solid, we will say that the vegetables will not be able to washed in this.
Even if they get washed the water will not drain out and the vegetables will not get dry.
So, looking form outside we get to know that what is the use of the utensil.
In the same way the data types in the variables which means what type of values are getting stored in it.
Who would be telling that? Our data types would be telling that.
Like you must be seeing here in the example.
Till now you must have understood that the RES that you are seeing, this is basically a variable and 5 is the value that we are storing in this RES.
Now, who is telling that there must be only numerical values that must gone into it? There must not be any such value in which there are characters or which has strings, which means there is a sentence in English.
Who is defining this thing? This thing is defined by int, which we have written before the variable, INT.
Now, how will the int define it and what is it trying to say, what would be its range? All these things we will discuss in the coming slides.
So, what is a data type? A data type specifies what type of data a variable can store, such as integer.
The integer type values like we are seeing here in the example, 5 is one integer value.
That’s why we have written INT in front of it, so that the computer or the complier gets to know that in this the integer value will come.
After that it can also be floating.
Floating means the decimal values, in which there are values even after the point.
So, floating values are done.
After that there can be character type values in any variable.
What are these characters, the characters can be a, b, c…so this is a single character.
Which means it will not have a word or a sentence.
There can only be a letter of English or of any other language.
It can also be a special symbol.
So, we will call it a character.
So, we are able to store different types of values.
So, who defines this? This is defined by the data type.
And, to define these there are specific keywords, like we had learned in the last videos that these keywords are reserved for special meaning.
These cannot be used in the identifier’s name.
So, that is reason the keywords like int, float, char, etc.
which you can see in the examples, with these keywords we define the type of our variable and which type of values would be stored in it.
Now we will go ahead and see, how many types of data types are there.
Okay.
So, the data types would be basically of 4 types.
So, we are making these 4 categorizations.
So, the first categorization is basic and then comes derived data type, then comes enumeration data type and at the end there is void data type.
We will see them all.
First, we will start with the basic data type as we must always start from the small or the basic one.
So, we will first of all discuss the basic data type.
What are basic data types? The basic data types are integer- based and floating-point based.
Now what does this mean? The basic types that are there in our C programming language.
What are those? They are either integer based.
Means there must be integer type value is stored in it or there must be some decimal or character type value stored in it.
So, we will see which all thing comes in our basic data types and which all don’t come.
We will even see that in the coming up slides.
For once lets also see these examples quickly.
The first example that we are seeing here is “int res = 5”.
So, res is our variable in which we have stored the values 5.
And what is its data type defining? INT, INT which means integer.
In res there will always be an integer type value.
We all have learned in maths what are integers.
So, we can see according to that which all values are eligible in it and which all are not.
After that we will go to the second example which you can see here is “char b = ‘G’”.
This means char and the variable after that in which some value has been stored, its name is b, right.
So, b has become an identifier like we have discussed the last time.
So, b is our variable and we have given one identifier in it, which we are calling as b.
Okay.
Now in variable b the value that is getting stored, we can see that it is g that is getting stored and we have put g in quotes.
Why? Because it is a character.
So, basically what happens in the programming language, these quotes define that this value is a number value or not.
Is it a numerical value or not? So, here we can see that g is not one numerical value.
That is the reason we have put it in single quotes, with which we are getting to know that this is not a numerical value.
And the data type that is written ahead CHAR, which means we call it char.
What is this char telling us? It is telling us that in the b variable a character type data only can be stored, an integer cannot be stored in it.
Any decimal value cannot be stored in it.
In this only character will be stored.
What is a character? Any letter or symbol from different languages, that can be stored.
Now we can even see this in it, there is 5 here, we can assume 5 to be a character and insert in it.
The char data type variable, in that we can even store 5 but there would be a different way to store it.
We have to put even 5 in single quotes.
You can put anything in single quotes, numerical or not.
This will not make a difference.
It will directly consider the value.
So, the char data type finds that the data that is coming in, is that in single quotes or is it single or not.
So, these things are seen by character data type.
After that we saw float in the example.
What is float? Float defines the decimal value.
Like you can see in the example here, “ZAB1”, would be a variable’s name and this is valid as its number is not coming in the front.
If the number would have been in front of z, it would have been invalid.
But here 1 is after zab1.
So, this is a valid identifiers name.
And that is the reason it is also a valid variable.
So, now what is the value getting stored in the variable? 5.34.
So, how is this 5.34 value is getting stored? Because we have defined float as the data type.
Float means the floating-point numbers.
So, floating-point means the decimal.
That is the reason why the decimal value is being able to store in the float “zab1”.
So, these are all basic data types.
Going ahead we will see the complete list, in the next slide which are our basic data types.
Now, we will see few more additional things about them.
So, we will directly move on to that slide and quickly see what are they trying to say.
So, we have this table in this, at the left-hand side you can see a table, which comes under basic data types.
Apart from these there are few in the next slide.
So, we will quickly see one by one.
So, the char data type that we saw before, in that the memory size, which means the hard disk that is there inside our CPU.
In that how much memory it is consuming? Whenever we will make a variable or we will make any such space in our program, in which any value has to be stored.
So, it will obviously take some space in our system or in our computer.
And what would be the size of that space? That would be of 1 byte size.
If its data type is a character.
Which means the data type is of CHAR.
And how is the range getting defined? The range is getting defined by -128 to 127.
So, this is the range.
Means inside this number, means the character inside this range, those we can insert in character type data types.
In the same way there are few similar to character things like we can see, signed char, unsigned char, short, signed short, unsigned short.
So, this signed, unsigned, you must be seeing in lot of places.
This signed and unsigned also let’s understand.
Like we have to store the memory in one place.
That memory will eat 1 byte, which means that it will consume 1 byte area only.
But if we say that we will store only positive number here and not the negative number.
Which means we will keep our data unsigned.
So, what will happen in unsigned, all the values will be positive.
So, you can see in the range here, the 1st range was -128 to 127, in signed char.
Which means where that the character will also consider negative values.
And if we make it unsigned, unsigned means only positive values will come.
In that case our range will start from 0 rather than negative values.
So, this is a thing to keep in mind.
All these types of variables we will use.
We will use data types of these types.
We will quickly understand these things and we will see that this short, character, this INT of integer, all these things we will understand very easily.
Quickly we will go through what will be its memory size? We saw that of short it would be 2 bytes.
After that int, means if any integer number we are storing, to store that in our computer, we will require the space of 2 bytes.
And there are how many bits in one byte? There are 8 bits.
So, these are few basic things, which we have to understand and in which way the data is getting stored in our computer, even that we will see.
Int is occupying 2 bytes memory space in our computer.
Now, everyone knows that the memory in our computer is 500GB or sometimes it is 1TB.
This GB and TB characterization is Gigabytes, then is Terabytes.
So, the number of bytes in it are exponentially increasing.
So, we can consider a big amount of data or memory size, in it.
And in it if we define any small, short variable type.
So, it will not make much difference in its memory as it is consuming only 2 bytes space.
In the same way if we look ahead there are few more types of data types, which are coming under basic data types, short int, signed short int, unsigned short int, long int.
So, all these memory sizes you can see, you can see its ranges.
For now, you don’t have to remember the ranges.
As and when you will use it…even from these not much would be used.
The basic ones will be used at the start.
As we would not be playing with such big values.
So, for now the basic ones that we have seen, integer or the floating point one or the character one.
Only these things we have to see.
And slowly we will see the signed, unsigned, short, long data types as well.
So, now we saw what are the basic data types.
The 2nd one that we saw was the derived data types.
Now, what will be derived data types? Like we saw the basic data types which was integer, floating point or it was any other character.
There are few more data types that have been derived from all these data types, which are called arrays, pointers, union or structure.
So, these are different types of derived data types and these are extensively used in C programming and these are very easy to use.
As and when we will understand them, we will have fun using them.
So, for now we will not go much deep in it.
In the coming videos we will consider each derived data type and we will understand how it works, what are the values that will come in it and which will not come.
So, as an example we can see an image here.
Where we are seeing few boxes.
We are seeing 4 boxes in which there are few values stored, which can be 90, 80, 56, 100.
So, this is an array and there is a name given to it which is grades.
For now, don’t concentrate on this much.
We just have to understand.
What is array? It is a list of boxes and these boxes are nothing but we have to store values in those boxes.
Now the values that would be stored which types of values those would be? Those are defined by these arrays.
That is the reason we have to consider it in derived data types.
Like arrays there are pointers.
Pointers help us to know the exact memory location of a particular variable.
We get to know all these things with the help of pointers and we can directly point at that memory location.
For now, you don’t have to deep dive into this.
We will read each and every data type and understand it, consider it.
For now, you should only have to understand the names, that would be enough for us.
Like we said, the basic data types were there, these are derived from it and have become derived data types which are called as arrays, pointers, union or structure.
So, these are 4 types of derived data types.
Which we will learn deeply in the coming slides or the coming videos.
Let’s go ahead and see the 3rd type of data type, which we had seen.
The 3rd type of data type’s name is enumeration data type.
Now, even this is one user defined data type.
How user defined? It means, we programmer who are making the programs, we can make the data types as per our requirements and conditions.
It means like we wanted an integer value, then the integer type data type is already there, the float one is also already there.
But we want a different type of data type, in which we can put the things as per the requirement of the program.
That condition is satisfied by the Enumeration data type.
How does it do it? Let’s understand it quickly with a basic example.
We have to number the weekdays like Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
Suppose 1 will be Monday, 2 will be Tuesday, in this way it will go up till Saturday.
And the value of Sunday will be 0.
Now each of these words, like we have defined 0 for a Sunday, we have to give 1 to Monday, 2 for Tuesday, in the same way 3 for Wednesday.
So, these numbers we have to assign to the particular names of the weekdays so that whenever we are using it ahead, we can even call it by its numbers.
This thing we have to do.
This thing happens easily with Enumeration Data Type.
There is not much difficulty in it.
We have to only write “enum” named data type and in front of it, our variable name.
And in this way very easily our requirement gets satisfied.
Even this thing we will see going ahead.
For now, only for the characterization, what will be the name of the topic, which means how many types of data types are there, for that we are understanding what would Enumeration mean, what would derived data types mean.
We saw basic data types, then we saw derived data types, then we saw enumeration data types.
Now the last data type is void data type.
What is this void data type? Since we wanted integer value, so we said, let’s give int.
We wanted floating point value or decimal value.
We gave float.
In the same way we wanted character so we gave character.
Now we want such a data type which doesn’t have any value, which means we don’t store any value in it.
We should keep it empty and use it.
Now why we have to use it keeping empty? How will we use it? How will it benefit? All these things we will understand as and when we will do the programs.
You will understand it then.
But for now, we will assume that we have to keep such a variable in which we don’t have to put any value.
It should be completely empty.
It should not have any specific type.
So, what we will do is we will consider that variable in Void Data Type.
What will happen if we consider it in Void? Void is such a data type which doesn’t have its type.
It means it is an empty type.
So, void is an empty data type that has no value.
For now, if we have to make a variable in which we don’t want to store any value and it should be completely empty.
We can make its data type void.
So, we saw the data types in this way.
First, we saw basic data types, then we saw derived data types, then we saw enumeration data types, which were user defined.
After that we saw void data type.
Now we have got a basic program, if we can quickly switch on to it.
So, this text editor that we have, there I have written a small program.
We will quickly understand this program and we will see that the data types that are there, which you can see here.
With INT we have defined the data types.
So, we will understand these things quickly.
Now we know that the lines starting from hash, this means that these are preprocessor commands.
It means that we wanted few files by default in the program, which we can use.
That is the reason why we have written these two lines, preprocessor commands.
Now, what will this conio.h file do? We will see that.
For now, we will understand it this way.
Both these lines are working as external files in our program.
From these we are using few things in our program.
Going ahead we will see; this is our main function.
We remember that we had learned the main function.
Like the main entrance of our house is from where we enter and exit the house.
In the same way the execution of the compiler, it will be after our main function.
So, this will remain as our main part of the code.
So, this is our main part of the code, we will see here what we have written in the 1st line.
In the 1st line we have written INT, we just now read, in basic data types, int in it is integer data type.
In the name of integer data type, we have defined these 3 variables.
Which is num1, num2 and result.
Basically, this is a program of any 2 numbers, to print the result after the addition.
So, here you can see that one number will come in num1, second number will come in num2 and the third one, which means it would be the result, after adding both, that would be our result variable, it will come in that.
So, all three types we have kept as integer type as we will do the addition in numbers itself.
And since it is basic, we will currently do it on integer numbers.
Here we can see that we have put 2 in num1, 3 we have put in num2.
Now basically what we are doing is, we wish to do 2+3.
So, what we will write in the program num1+num2, which means 2+3.
When we will call here num1 or we will write num1.
So, what is happening here in the background.
Num1 will be replaced with 2.
And num2 will be replaced with 3.
As soon as we are writing it and putting it in result variable, in this way, in this line.
What will happen? Num1+ num2 will happen, 2+3 will happen and the value that is coming.
Which means that we know that 2+3 is 5.
So, this 5 will come in this result.
In this result our value has come, that means 5 has come.
Now we have to show that on the screen.
How will we know that our addition is successful or not? So, what we will do is we will print it with printf function.
So, we will use printf function.
We already know that we use printf so that we can print the code or the answer on the screen.
So, we are using this printf function.
And this syntax we have made using %d and we have written the result by writing the comma.
We will not consider this syntax for now.
We will just understand that this printf function, what is it doing? It will help us to print the answer that is saved inside the result, which means that it will display on our screen.
We will quickly run it; we will right click and click on run code.
And you can see here that 5 value has been printed here, which means that we have seen here, num1+num2=result, which means that it has gone into the result and when we printed the result, its value has come as 5.
In the same way we will make a lot of programs.
And we will see how going ahead variables will be used, data types will be used, for now this was a small example, form where we could see that the integer type data type we were talking about, how does it work.
If you think that there is any part of this video or this topic, you might have not understood then you can ask us any query or question related to that topic without any inhibition.
You just have to go on forums.learnvern.com, you have to type your query there in your own language and we will come up there with the solution or the answer as soon as possible in your own language.
Apart from this if you wish to have a discussion on any topic.
Even that you will be able to do on fourms.learnvern.com.
The next topic we will see about variables.
Till now we have got a lot of information and knowledge on what is variables.
But exactly and specifically why is variable used, how are they made and how will they be used.
We will discuss all these things in the next video.
Till that time thank you so much.
Thank you everyone.
Share a personalized message with your friends.