Capitalised all the Alphabets required in the equation.
My name is (name) and we are continuing this C programming course.
In the last video, we had discussed constants in C programming, which means what are the types of constants, they are of how many types, how are they used and what are the ways to make them.
All these things we had discussed in the previous video.
There are two ways to make them constant, the first is by using a hash define preprocessor, after that the second part or the second way is by using CONST keyword, this is the way to make the constants.
Then we saw practically how we wanted to change the values but the values were not changing because we had made them constants.
After seeing constant, now is the time to see operators in C.
We have seen a lot of operators in mathematics like addition operators, subtraction operators, multiplication or division and many other operators we have explored in mathematics.
In the same way, there are few operators in C programming as well.
In general programming also, there are different types of operators and they have different functionalities.
So, how many types are there, how to use them and after using them what is the functionality that comes in use.
We are going to see all these things in this video.
We will start with a simple definition.
The definition says that it is “a symbol that takes one or more operators such as variables, expression or values and operates on them to give an output”, which means if you take any two operands, two or one you can take as many, they should be more than one.
Operates means take any two values.
In values, we can even take variables because there are values in variables.
So, we took two variables and in between those two variables, we have put one symbol, one operator with which the entire meaning of the statement changed.
Like between A and B we have put a plus sign, what we are saying is add A and B, make a sum of them.
In this way, there are different types of operators and they have different meanings.
For example, we can see here minus, equal to, plus, division, multiplication, there is double equal to as well, double plus, double minus, percentage sign which we call as modulo.
So, these are different types of operators which we will see and understand one by one.
So, going ahead we will see how many types of operators are used in the C programming language.
There are in total six types.
First is arithmetic operators, second is relational operators, third is logical, assignment operators, bitwise operators and miscellaneous operators.
So, these are six types of operators, we will understand each one of them, how they work and after understanding that, we will also practically use them, how their functionality works.
We will see all these things, the names will seem a little complex but as and when we will understand their meanings and we will understand which are their operators, it will be easy for us to understand.
Without any delay, we will see the first type which we call “arithmetic operators”.
From these, we have seen most of them in mathematics like addition, subtraction, multiplication, division after that there is modulo operator.
What does the modulo operator do is if in between any two operators if we put the modulo operator after dividing the both the remainder that is left, not the quotient, the remainder that is left, it gives that as an output.
In the same way, what is the meaning of double plus and double minus, double plus mean in front of whichever variable you put this double plus, it will mean that one should be added to it, which means if you put plus, plus before A that will mean that you are saying make it a plus one, add one with the A value.
In the same way if you put double minus, what will happen in the minus is the value in A minus one from it.
Which means that if there were five inside A and we did A minus minus, then five minus one four, so A’s value is now four.
The operators are in this way, we saw that these are called arithmetic operators.
After this comes our “relational operators”.
Operators are the ones who tell the relationship between any two numbers.
Now what does this double equal to sign means? Like we have taken two variables A and B.
There were five in A and three in B we have put this double equal to operator between the both.
We said A double equal to B so what will be its output? Double equal to means it checks if both are equal.
Since A had 5 and B had 3, so they both are not equal.
So, what will be the value that it will give? It will output the value zero means this statement A double equal to B, if it would have been true or correct, it would return the value one.
One means the true value, which means the statement that we are checking is true.
In the same way, if the value comes out zero, it means that the statement that we are checking is false, it is wrong that is why its value has come to 0.
So, in programming whenever value is coming as 1, it means the statement is true.
If it comes as zero it means that statement is false.
Slowly as and when we will use it and get used to it then we will find these things very easy.
Now we will see greater than, less than, all these symbols we have seen already.
After that, there is one operator exclamation mark and is equal to one. What is this? In an example we would see 5 not equal to 3. If we read it in this way, the exclamation mark and is equal to, we read it as not equal to.
Is 5 not equal to 3? We know that 5 and 3 are not equal.
That is the reason why the compiler gives us the output as 1 because this statement is correct.
5 is not equal to 3.
That is the reason it gives 1. - 06:58
In the same way, there is greater than and equal to and less than or equal to is also there.
So, all these are our relational operators that tell the relation between the two numbers or values and give us the output values 1 or 0.
1 means true and 0 means false.
We'll go ahead and see what the logical operators are.
We have seen that two ands are made, we call these logical “ands”.
What does this mean? If we see in the example, we have taken C is equal to 5 and D is equal to 2.
But if we put in this condition where you can see C is equal to-equal to 5 and D is greater than 5.
So, we know that D is not greater than 5.
Apart from that is C equal to, equal to 5? Yes, C is equal to-equal to 5 means C's value is actually 5.
So, 5 is equal to 5, so the first statement is true.
But the second statement which was there which said D is greater than five, is it so? But D is 2, 2 is smaller than 5.
So, this is wrong.
Its value is 0.
When its value had come as 1 and its value had come as 0, in between them if we put the “and” operator.
It means that between 1 and 0 we had put “and” operator.
Now what does and means between one and zero, and means when both the values are one at that time the “ands” output that will come even that will be 1.
Apart from that, if one value is 1 or 0 and the other value is 0.
In the same way if the first value is zero and the second is one in that condition.
This “and” operator gives the output as 0.
Means when both its values are 1, C is equal to-is equal to 5.
Its value is 1 but if it would be 1 of the other statement as well.
So, if we would put “and” in between those two.
In that case, our output would have been 1.
Otherwise in other conditions that becomes 0.
When we will use it, we will know more about it, in the same way there are two lines.
What do these two lines say? It is the same concept.
1 will come for this and this will be 0.
But what is the meaning of these two lines? From these two, anyone should come as 1.
In that case, this “or”, the two lines which are visible, its output will also be 1.
So, you can see here that the expression was this and it becomes equal to 1.
In the same way this exclamation mark is there.
We call it “not and true only if the operand is 0”, which means we saw that in C five was stored and we have written this expression, check C if it's equal to 5, if it is then add this exclamation mark which means make it “not”.
What will happen now, 5 is in C.
So, the condition will be 1 but after that the exclamation mark will reverse it, which means if 1 comes, it will make it 0.
If 0 comes, it will make it 1.
In the same way it makes it vice versa.
If it is 1 then 0 and if it is 0 then 1 that's the reason it is called as “not operator”.
As and when we will use these logical operators, we will understand the actual meanings of these.
So, we have seen arithmetical, relational and logical.
Now we will see assignment operators.
In assignment operators, one is equal to sign, like we define any variable, R E S=5.
So, what does that mean? The value 5 got stores in R E S.
It means that value 5 has been assigned in R E S.
That's the reason it is called an “assignment operator”.
There are many apart from this assignment operator like multiply equal to, minus equal to, divide equal to or plus equal to.
There are also other types of assignment operators.
How do they work? You can see in this example, if you write Cplus equal to 15, so what will it mean? C is equal to, C will come back plus 15 means the present value of C, the current value of C in that 15 will be added, this symbol means that.
Going ahead as the symbols will change instead of plus, minus, multiply or divide will come in the same way the below statement also the symbols will change.
So, we saw a few assignment operators as well.
Going ahead we will see Bitwise operators, there are Bitwise AND, OR, exclusive OR, complement, shift left, shift right.
So, these are such kinds of operators that the values in between such operators are used.
These values are basically converted into bits by the operators.
Bits, we must be remembering, we had seen that in binary language it breaks all the things in 0 and 1 form.
In the same way these bitwise operators also convert them into bit forms and then conduct the operations because of which the operation becomes quick because the bit language is understood by the computer.
That is a reason why the operations run over bits.
Which means the bits that are there, 0’s and 1’s, on these operations that are happening, they are very fast and that is the reason we use these bitwise operators.
We will go ahead and use them and see how they work.
Apart from them there is one additional operator as well.
Which is a Miscellaneous operator.
As we are saying there is the “sizeof” operator.
If you put any variable inside it, it will tell you what will be its size, which means how many bytes space it will use.
In the same way there is “and”, “and” will tell that in which location that particular value is stored, and what its address is.
In the same way there is a “star” which is used in the pointer, these things we will learn going ahead.
These concepts we have not learned till now as we are at the beginning stage.
We will slowly pace up and slowly after practising we will understand the meaning and use of all these operators.
Now after seeing them theoretically, we will quickly explore it practically as well and understand how it works.
We saw “arithmetic operators”.
So, you can see here a + b.
I have made a program over here where I have kept the A’s value as 9 and B’s value as 4.
And I have made one more variable C.
Now I have made a+b, 9+4.
What is 9 plus 4? It’s 13.
13 got stored in c and then I got it printed with the help of print F statement.
After that, this A modulo B, which means if we will do A divided B.
The reminder that will come will also be stored in C.
When it was stored in C, again with the help of print F, I got it printed.
So, we will quickly see how the output of it is coming.
So, both of these are arithmetic operators as we had read and their output will also come very easily.
We have made the lines below this into comments.
We will remove them from comments and execute them one by one, run them and understand their meaning.
For now, we will concentrate only on these four lines.
I've already saved it.
I will right click and run the code, see on my terminal how it happens.
If you see the output, A’s value was 9 and B’s value is 4, if we do a+b, the value comes as 13, in the same way if we do A divided by B, which means nine divided by 4, our remainder would be 1.
So, 1 has come as output here.
Because of what it came? It came with the help of a modulo operator.
So, in the same way we saw arithmetic operators.
Now we will use other types of operators.
For that first of all I will comment these.
And we know that the comments are ignored by the compiler.
And to make them comment so that afterwards we can uncomment it and use it.
So, what will we have to do to make it a comment?
You just have to select it and form your press Ctrl plus forward slash button and these comments will be made.
Now these comments are made.
Now we will uncomment the second one, we will press the same keys Ctrl plus forward slash.
This has got uncommented, here if you can see we have made use of double plus.
Double plus means making A plus and double minus means B minus 1.
So, in this way it will work.
As you can see that A and B's values are 9 and 4 respectively.
Since this is not saved, I will press Ctrl+S, save it and I will right click it and run it.
As soon as I press run code, you can see what the output that has come.
Output of A came as 10, first it was 9, when we did plus, plus 1 got added to it, its value became 10.
In the same way, since we had put double minus, double minus means B-1, B’s value was 4, if we do 4 minus1, the value will be 3.
So, these are called increment or decrement operators which actually come in arithmetics.
So, we have explored even this, so we'll make them into comments with the help of ctrl plus forward slash.
Going ahead we will see this thing.
So, what is this? Whichever value was under A, we have put it in C.
It was 9.
What will happen to the C’s value? It also became 9.
So, we can see here that C is equal to we'll get the value printed of C so here C is not 5 actually, C will become 9 here.
(repeat) Now when we will do C is equal to A so what should be its value, its value will be A plus C.
So, in C there was already A’s value, so 9+9.
What is 9+9, it is 18.
So, in that way, C’s value becomes 18.
We will quickly see how it will work with our print F statement.
I will save it and run it again.
You will see here earlier the C’s value was 9 since we had put A’s value inside it after that, we used this and what does it mean indirectly.
Indirectly it means that C is equal to C plus whichever the A variable was.
So, this is its meaning.
So, we had 9 in C, 9 plus A was 9.
9 plus 9 is 18.
That will be stored in C.
Then again when we got it printed you can see that 18 has got printed.
In this way, we explored our C is equal to A assignment operators.
Now we will comment them with the help of ctrl plus forward slash.
Going ahead we will see some “relational operators”.
These are relational operators double equal to, double equal to, greater than, greater than, we have A and B values.
And we are checking if A and B are equal, A and C are equal.
Since even C is being used, we will give one value to C for now which will have the value as 1.
Its value has become one.
Now we will go down and run all these statements.
With this you will easily understand what it's actual meaning is.
What is 9 equal to, equal to, is it 4? No, so its value is false, which means 0.
Is 9 equal to, equal to 1? No, so even this will become false.
Now is 9 greater than 4? Yes, it is so its value is 1.
And is 9 greater than 1, that is also right.
So, even this is true.
So even its value is one.
The output of these relational operators is 1 or 0.
True or false.
So, in this way our relational operators also work, we will make them comment again and quickly see the last type of operators which are “logical operators”.
What do these logical operators do? They check whether A and B are equal or not.
And they will check if C is bigger than B.
If any of the two conditions are false then even “and” operator will print false.
So, we quickly see it, we'll save it and we will right click and run it.
You will see that since A equal to-equal to B is incorrect, A was 9, B was 4, along with it C is also 1 and B was 4.
So, even this statement is incorrect.
Both are 0.
What will the “and” operator do? “And” wants both as 1, only then it will give true or 1.
So, when both were 0 even the “and” operator’s output came as 0.
You can see here that there was a format specifier so the result got printed here.
So, in this way there are different operators and they have different meanings, there are different ways of using them.
How few operators use two variables, few operators finish their work in one variable.
In this way, the operators work in C programming.
And we saw logical, assignment, arithmetic, relational.
We saw different types of operators & understood how they work.
We will see Miscellaneous and bitwise operators in the coming videos so that for now it doesn't become very complex, for now the operators that we have seen we will practice only those.
When we have the use of miscellaneous and bitwise operators only then we will learn them.
Till that time, thank you so much before we will discuss… 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.
If you have any queries or comments, click the discussion button below the video and post there. This way, you will be able to connect to fellow learners and discuss the course. Also, Our Team will try to solve your query.
What are we going to discuss in the coming up topics? Flow control and decision making, which means in C programming how we can make decisions.
If this value is 1 what we have to do and if it is not 1, what we have to do.
We will be able to make these kinds of decisions and also be able to control the flow of our program with the help of a few values.
So, until that time, thank you so much we will meet in the next video.
Share a personalized message with your friends.