Transcript for:
Notes on Operators in C Programming

In today's lecture we are going to cover Motivation and Introduction to operators in C. Suppose, I ask you to write program to find the area of the rectangular garden provided that the length to find the area of the rectangular garden provided that the length of the rectangular garden is 15 meters and breadth is 10 meters. Suppose this is the rectangular garden, and I ask you to write a program to find the area of this rectangular garden and I provided you the length of the rectangular garden as well as the breadth of the rectangular garden. and I provided you the length of the rectangular garden as well as the breadth of the rectangular garden. What do you need to do to find the area of the rectangular garden? You simply multiply length and breadth together and this will give you the area. That mean, somewhere in the program you need to multiply these two values. Therefore, what we need is to multiply these two values. Suppose I ask you to write a program to check if annual turnover of you company is greater than or equal to the annual turnover of you competitor. Now suppose, that annual turnover of your company is 300000000 and the annual turnover of your competitor's company is 500000000. Now what do you need to do? You need to compare these two values right? If you want to perform the comparison between these two values then, you need to have a greater than, equal to operator and that's what you need to do inside your program. Finally suppose I ask you to write a program to make a decision that if you have both chair and table, then you start studying your favorite subject otherwise you simply go to sleep. What i am asking you is that, if you have both chair and table, then you start studying otherwise you go to sleep. What am I discussing all these programs? What is the need of discussing all the programs. What you did in the first program is that, you multiply these two values. 15 and 10. Multiplication operator in C programming is also called as arithmetic operator. Note down this thing. What did you do when you compared the turnover of the two companies? You apply an operator, which is greater than, equal to. This operator is also called as relational operator in C programming. Because this operator is used to find out the relation between two values therefore, this operator is also called as relational operator. In the third program we checked this condition, that if we have both chair and table, then we are going to study otherwise we simply go to sleep. Right? With the help of ampersand ampersand (&&) operator we would be able to check if both conditions are satisfied. Not only just a single one, if both conditions are satisfied then we will go to study otherwise we simply go to sleep. Now why am I discussing all these programs? Now, what is the need of discussing all these programs? Why are we studying operators? What is the need of studying operators? Motivation behind studying operators is that, without operators such calculations are impossible. if you want to perform division, if you want to perform multiplication, may be you want to compare the two values, may be you want to satisfy the conditions like these, them in that case, you need operators. Without operators no programming language is possible. Operators are the foundation of the programming languages. Therefore they are required. C programming language also provides us different kind of operators. Now we are going to discuss about them. There are different types of operators supported in C. And the first category of operators, are the Arithmetic operators. Arithmetic operators such as + , - , * , / , %. The second category of operators supported in C are Increment and Decrement operators. This one is called Increment operator and this one is called Decrement operator We are going to have a lot of discussion about this topic later on. Then the third category of operators are the Relational operators. This one is called is equal to operator, this one is not equal to operator, this is less than equal to operator, this is greater than equal to operator, this is less than and this is greater than, Now the fourth category of operators are the Logical operators. This is ampersand ampersand which is also called as AND. This is OR This is NOT. Fifth category of operators are the Bitwise operators. They are Bitwise AND, Bitwise X-OR Bitwise OR Bitwise 1's compliment operator Right shift operator and Left shift operator. Then we have assignment operators such as this is simply an assignment operator, this is increment then assign, this is decrement then assign, this is multiply then assign, this is divide then assign, this is modulus then assign, this one is left shift then assign, this one is right shift then assign, this one is Bitwise AND then assign, Bitwise X-OR then assign, Bitwise OR then assign. The rest of the operators are Conditional operator like this one, the ampersand which is also called as address of operator. This is star operator which used in pointers, we are going to have a discussion about them later on. sizeof operator which we already studied and the comma operator which is very important to know. OK friends, this is it for now. Thank you for watching this lecture.