 Hello everyone. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So this is day four of C and C++ coding bootcamp. And today we are going to learn about operators in C. So before I start, so let's wait for a couple of more minutes so that more folks can join and then we'll be starting. So till the time I just want to show you the session tracker which I have created for this bootcamp. So basically the objective of this bootcamp is to help BTEC students, freshers, non-tech folks and career gap folks, those who are struggling with understanding programming. So if you know the basics of programming then learning difficult programming languages is easy. Like if you want to learn Apex and Java, so for those programming languages basis C and C++. Right? So for any beginner, if you have not done BTEC, then also you need to understand C and C++. If you are in BTEC, then also you need to understand C and C++. So understanding these two programming languages is must. Right? So to accomplish that requirement, I am just conducting this bootcamp for you so that you can understand the core concepts of programming with the help of these programming languages. Right? So in today's topic we'll be understanding about operators in C. So if you see the session tracker, so you can see there are total three sessions that I will be doing this week. So first I will be explaining you about operators in C and we'll be covering four different types of operator and I will be explaining each and every operator in detail because when we learn Apex programming or Java programming, so we focus on lots of operators and at that time it is very difficult to understand the need of those because no one explains those operators in detail while you learn those programming languages. Right? So here in this session, I will be going and will be deep diving so that I can explain uses of each and every operator to you. Okay? So moving forward, so again I think I just want to show you like who is your instructor. So if you are related to Salesforce bootcamp, then you know me and if you are new and watching the recording and you are becoming part, first time part of this channel or bootcamp, so you should know who is your instructor. So I have 16 plus years of experience, lots of experience related to education, education industry and six plus years of experience in IT industry. Right? So be consistent, do regular practice or whatever I am explaining in the sessions, so do regular practice on those. If you are a beginner, like don't know anything about coding, then this bootcamp is very helpful for you and if you are a BTEC student, then also it is very, very much important for you and join the self help group where you can ask any questions related to this C and C++ programming languages and follow Sanjay Gupta Tech School on YouTube, LinkedIn, Instagram and Telegram and all the important links like session tracker is available in the videos description, so you can find it from there. Okay, let's focus on the topic. So we need to understand what operator is and how we can use operators in C programming. So this is very important topic if we talk about C programming. So first of all, we need to understand what operator is. So if we talk about mathematics and mathematics also, we have operators, right? So if we say an operator is a symbol, which is used to evaluate an expression, so that will be known as an operator, right? If you see this example, here it is written like C equals to A plus B. So this whole statement is an expression. Okay, this whole statement is an expression, but here you can see we have C equals to A plus B. So if you see the bottom line which says equals to and plus are operators, whereas A, B, C are operands. Okay, so operands means you can say these are variables or these can be constants as well, but equals to and plus these are two symbols which are working as operators here. Okay, so I hope you understood whatever I explained with the help of this slide. Now moving forward and anytime if you have any question you can ask. So we have three types of operators based on operands. So this is particularly related to C. And in Java and C, Apex as well, we have all these things like unary operator, binary operator and ternary operator. Okay, so if we talk about unary operator, so here we have one operand and one operator. So I hope with this previous slide you got to know what is operator and what is operand. So basically operator is the symbol and operands means variable or constant. Okay, so here if we move forward so now I hope with the help of this previous slide definition, you are clear with this operand and operator thing. Okay, so if you have one operator, one operand, so that will be unary operator. If for any operator, two operands are required. For example, plus. So for plus you need to have two operands. We can add add two numbers with the help of plus. Right, so that is why that plus will be considered as binary operator. And then we have ternary operator where two operators and three operands will be required. Right, so this is the classification and the ternary operator we use in Java and Apex as well in C++ also and unary binary as well we use in most of the programming languages. Right, so these are the classification based on operands. Now if we go forward, so these are types of operators. Those are available in C programming or these are available in other programming languages as well. So if you have gone through Java or if you have gone through Apex, so there you might have used all these symbols like in different calculations. Okay, so we will be understanding these operators one by one. Right, so in today's session, I will be explaining arithmetic, relational, logical and increment and decrement. So with the help of example, I will be explaining you all these operators. Okay, so these are types of operators based on operations. So this is the list. Now if we move forward, so first of all, we need to understand what arithmetic operators are. So we have plus, minus, multiply, divide and modulus. Okay, so these are five operators which are available. Fifth one is known as modulus. So for understanding purpose, let me come here. And here I'm going to have an example so that you can understand the working of each and every operator. Okay, so first of all, if we use A plus B, right, so I'm writing total five statements and you guys need to answer this in the chat so that we can match our answer. So fifth one is basically modulus. So percent means modulus operator. It is also known as more. Right. And what it does, it provides remainder value. It provides remainder value. And if we talk about divide, so divide provides basically quotient value. Okay, so these three are very simple plus minus multiplier and we have divide and modulus. So basically what we need to do, you need to tell me the answer of line number 9 and 10. So in the chat, you need to post your answers for line number 9 and 10. What will be the result of 9 line number 9 and what will be the result of line number 10? And A is 5 and B is 2. So quickly type your responses in the chat so that I can see if you have understood incorrectly, so I will be explaining it that way. And divide we frequently used in using Apex and Java as well. And for modulus, we have a predefined function that is known as mod. But here you should know its meaning. So quickly tell me the response in the chat so that we can make it an interactive session. So I'm waiting for your responses so that I can check. Otherwise, I will be explaining. So Abhiram is saying 2 and 1. So yeah, 2 is correct for this. For line number 9 answer will be 2. How so? Because here we have data type as int. So whenever you divide any integer with integer, so result will be always integer. So 5 if you divide by 2, so it will be 2.5. But all the variables are of type integer. So that's why C will be having 2 as a result. Okay. And here we are using modulus. Modulus means remainder value. So if you try to divide 5 by 2, so remainder will be 1. So for line number 10, remainder will be 1. Okay. So savior, your answer is incorrect 2.5 won't be there because here our data type is int. So if we use float for this calculation, then your results should be 2.5. So this you need to remember. So I hope with this way, you are able to understand the meaning of each and every operator. So plus minus multiplier is same as we use in mathematics. Divide basically provides you quotient value, the result part, and modulus provides you the remainder value. Okay. So these are 5 arithmetic operators that we have in C programming. And in other programming languages also we use these operators. Okay. So I'm not saving this code and I'm going to pick next example. So next is relational operators, right? So here we have 6 symbols. So less than greater than less than equals to greater than equals to than double equals to and then not equals to. So initial 4 are like related to mathematics. And if we go further, number 5 and number 6, these are basically related to programming only in mathematics, you don't have double equals to, you don't have not equals to. Okay. So how we will be using them? So double equals to basically is used for comparison purpose. So if I write it like this, a equals to b and a not equals to b. So this way you will be able to use these operators, right? So this will be the meaning of this statement. So basically, this is a condition if if is a conditional operator where we can compare two entities. So here we are comparing a and b with the help of this equals to operator, right? So it will be comparing a and b if both are equal, then result will be true. Otherwise result will be false. Then at line number 10, we have a not equals to b. So both are separate. This is separate block. This is separate block. So here I'm not going to explain if condition if condition we will be understanding in the upcoming session. So what you can understand if is basically used to check the condition, how exactly it works that we'll be seeing in upcoming session. So here just understand how we can apply comparison. So if these two are equal, then this will be true. Otherwise false. This if is separate. So if here a is not equals to b. So this operator, it is known as not equals to, right? It is not equals to. So if a and b are not equal, then this condition will be true. So this is the case here. If both are unequal, then it will be true. Otherwise it will be considered as false. So this way you can use it. And if you want to use other relational operators, so what you can do, you can write a greater than b likewise. So if a is greater than b, then it will be true. Otherwise false. Then you can use less than less than equals to greater than equals to. So if you want to compare two entities anytime. So that's where these operators comes in the picture. And that is why these are known as relational operators because these operators are telling relationship between two operands with the help of one symbol, right? So here we have two operands a and b both are two operands and less than equals to double equals to these are symbols, right? So if you want to compare two entities, so for that purpose, basically, we use relational operators. Okay, so moving forward. Next we have logical operators. So logical operator is a little bit tricky and different. And in Java and Apex, we use them a lot. So before explaining the example, I just want to explain you an example, or you can say a table I want to discuss with you so that you can understand how exactly logical and and logical or works. So basically, this is a truth table in front of you. And if we talk about logical and and logical or so they are basically used on two operands. So two operands means two conditions will be there. So operand one is the first condition operand two is the second condition. So basically, if you want to apply two conditions together, so either you will be using logical and or you will be using logical or. Okay, so let me give you a brief example of this. And then we will be discussing the truth table. So here we have this condition. So this way, these are two conditions. So this is operand one a less than equals to be together, it will be treated as operand one, or you can say condition one, then a greater than C, this is operand two, or you can say this is a condition number two. And in between, we have logical and operator. So what is happening here, logical and is checking whether left hand side condition and the right hand side condition, both are true or anyone is true or both are false. So these are the three scenarios, right? But if you want to join two or more than two conditions together, then either you can use logical and or you can use logical or. Okay, so now comes now I let me come on this table. So here you can see we have operand one operand two and then we have these values. So if operand one like condition one is true and second condition is also true. So logical and will be considered as true and or will be considered as true. So what does it mean? So for example, suppose this is true. So a less than B. So let's say it is one and it is zero. So right now what is happening? A is less than equals to be true. A is greater than C true. So both the conditions are true. So it means what will happen true part of if will be executed. So basically if has two parts are true and false. So if if I write else here, so this is true block and this is false block, right? So this is true block and this is false block. So if both the conditions are true, so true block will be executed, whatever statement you will be having, they will be executed. But if both the conditions are false, so this else block will be executed and whatever you write here under else part, it will be executed. Right? So this way you use logical and so now if you go through the table, so if both the conditions are true, so and will be considered as true or will be true. If anyone is false, so if you go through second row, like true false or false true, so in both the cases and will be false and or will be true, right? So it means in case of and both the conditions should be true, then only it will be true. If you see the last, like both the conditions are false, so and will be false and or will be false. So the conclusion is if all the conditions are true, then logical and will become true. And if all the conditions are false, then only or will falls. If at least one condition is true or one operand is true, then logical or will be considered as true. Okay, so these are some scenarios. So now I'm going to ask few questions to you. So here I'm going to create this block and I will be modifying these conditions and you just need to mention in the chat like whether it will be true or false. So right now we have this example a less than equals to b and a greater than equals to c. So what will happen? It will be true or false. So as I already told you, this will be true because both the conditions are true. Okay, now I'm going to modify it a little bit. So a is for these two C zero. So this is false is less than equals to be which is false for is less than equals to be false. So if first condition is false, so second condition, if you check or don't check doesn't matter, right? So outcome will be false. So if you have this kind of scenario, a less than equals to be and a greater than c and if you have these type of values, so this condition will be false. Right, so this way if first part is false, second won't be checked in case of logical and now if first is true, let's say a greater than equals to be if first is true, then second will be checked whether it is true or false. So if I write a less than c, so second is false, but first is true. So first condition is true, then second condition will be checked, but overall result will be false because second condition is false. Right, so this way logical and works. Okay, now if I use logical or so what will happen? This first condition is true. So second won't be checked and it will become true. If first is false, then still second will be checked. If second is true, then overall result will be true. If second is false, then overall result will be false. Right, so now I'm going to modify it so a less than equals to be it is false, a less than c, it is also false. So result will be false. So in or if you if you have multiple conditions and if you have not achieved true, then all the conditions will be checked one by one. If you have true, then it will stop. If there is no true, then overall result will be false in case of or and in case of logical and if all the conditions are true, then result will be true. Otherwise result will be false. So I hope you are able to understand this truth table. Now what I'm going to show you like if you want to use multiple conditions more than two conditions, so that is also possible. So this way if you want to write this so it is possible. But here you need to use parenthesis like which condition you want to evaluate first. Otherwise it will go through precedence. So there is a precedence table. According to that, it will be executed. So we have a precedence table. So let me search that precedence table for you. So here you can see this is the precedence table. Precedence means order of operators execution, right? So it is true with all the programming languages. And here you can see we have and or right. So first and will be executed and then or and if your pride is like you want to evaluate or first and you don't want to evaluate or like if you want to give priority to any particular operator, so you can use parenthesis. So this way you can enclose. Now what will happen? First, this parenthesis will be solved. After that, this end and then this condition. Right? So this way this whole if condition will be evaluated. Right? So precedence is important and in any programming language, if you want to solve particular operator first, so you need to use these parenthesis. So this way, if you want to combine more than two conditions using logical and logical or so this is also possible. So I hope you understood this classification because as a beginner, this you need to know this is very important. Right? Now we have one more operator that is not third one. This is also important. So how it works? So for example, we have the situation a less than equals to b. We have the situation a less than equals to b. So right now what will happen? A is less than equals to b false. This is false, but I need to reverse the result. If it is true, I want false. If it is false, I want true. So what you need to do? You need to use this operator not. So this exclamation sign, but it is actually not operator. Right? This is exclamation sign, but it is actually not operator. So what it does? It converts true to false and false to true. So this is the behavior of this not operator. And if you remember in Apex programming, if you have gone through Apex programming, so in Apex programming, generally for list size check, we use it with is empty. Right? So whenever you want to reverse your decision, then we use not operator. Okay, so this is logical operator. So and then or they we use for joining multiple conditions and not basically converts the result of true into false and false into true. Right? So this is our fourth operator that you need to understand. Okay, so I hope this table is clear to everybody, those who are watching live or if you're watching the recording, I hope it is clear still you have any doubt. So you can ask in the chat or if you're watching the recording, you can ask your doubt in the comment section. And in the beginning of the video, I showed you a QR code for telegram groups. So you can join that group. And there I'm just collecting all the folks who are struggling with C and C++ programming. So if you have any doubt anytime, so you can just utilize that group. Okay, so next is increment or decrement operator. This is also important. So sometimes, if you want to increase value of a variable by one, or if you want to decrease value of a variable by one, then we use plus plus minus minus operator. Okay, that's why these are known as increment and decrement operator. So these are very easy to use. So this way you can write. So, so this way, basically, we can write them. So this is the one way a plus plus b minus minus so a will be incremented by one. So here if I write printf, or send a and if I copy paste, so let's execute this code. So initially a is four and B is two, and we are incrementing a by one, and we are decrementing b by one. So let's see what happens. I'm clicking on run. So here you can see the result is actually five and B is one. Right? Initially, a was four. So it became five. B was two. It became one. So this is the proof. If you apply the these operators plus plus minus minus. So the value of variable is basically incremented by one or decremented by one. Right? This is the one way of using this. If you want to use it like this, plus plus a or minus minus b. So this is also possible. It is basically known as pre increment or pre decrement. So here, I'm just clicking on run. So this time result will be same. This time result will be same. Right? So we just need to understand it this way only. If you want to increase or decrease, so you can use it before the variable, or you can use it after the variable. Right? So it will be incrementing value of a variable by one. And generally, we use these operators when we implement a loop. So in loop, basically, we need to implement value of a variable by one. So basically there, we use these operators to increase or decrease value of a variable by one. Right? So I hope this way you understood the uses of these operators as well. Okay, so this way, I in today's session, like it was shot. So these programming sessions are a little bit short. I'm keeping these shots so that they on daily basis, little bit idea you can get. So I just explained these four operators arithmetic relational logical and increment. Then tomorrow I will be explaining assignment operator conditional operator and classification based on unary binary ternary and we'll be understanding few examples as well. Okay, so this way, like this week, operator section will be completed. And next week, I will be focusing on the conditional statement, like how we can implement logical implementation with the help of code. And this is the time where most of the beginners struggle, right? So these these sessions will help you to understand the programming in better way. You have no experience of programming. Either you are BTEC student or fresher, or non tech folk or if you have career gap, and you want to brush up your programming skills. So these sessions will be beneficial for you. Okay, thank you, Badal for appreciating my efforts. And I can see, like, less folks are there. So I think everybody whatever I explained is clear to you. And those who are watching the recording, if you have any doubt, so just ask in the telegram group, or you can just write a comment in the video, so that I can answer. Okay, so with this note, thank you for joining this session. And if you're watching the recording, do follow all the sessions so that you learn programming easily. Thank you so much. See you tomorrow, same time.