 okay so I think now voice will be there so welcome everybody I am Sanjay Gupta and today we are having day 5 of CNC++ coding bootcamp so basically in the yesterday's session we discussed about operators in C and today also we'll be understanding about operators in C right so I hope now my voice is audible to you it was my bad like I was forgot to plug the audio cable so now I think you are able to listen me so we'll be discussing this so I was just explaining like if you don't know about me and joined this bootcamp for the first time so this is this slide is for me and like I am running this bootcamp so that I can help students, freshers, professionals like those who are from non-technical background and students those who are starting their beta career so this CNC++ coding bootcamp is for all so there is no ace to learn programming so like college beginner student as well as working professional any anyone anytime can start learning coding okay so consistency is the key so do regular practice and with this slide I just want to show you like today I created one exercise sheet as well for this bootcamp dedicatedly so if you click on this link exercise sheet link so here you will find a doc and if you click on this so here you will be having the complete session tracker or you can say day-wise exercise sheet so those who are following this bootcamp or in future like I am sure like lots of people will be following this bootcamp in future because all the sessions are recorded as well so for them I'm preparing this and for you those who are joining live and watching and following so all the programs that we are discussing in daily sessions those are listed here like in today's session we'll be discussing about these four problems right so these are simple problems initially but step by step you will see like problems will be having some difficulty level so if you if any by any chance if you struggled learning Java apex or you started any advanced programming languages directly so if you want to build your base so I think C programming is best for you okay so moving forward this group I created for like this bootcamp if you have any question any concerns so you can scan this QR code and you can ask any questions so just follow Sanjay Gupta Tech School on YouTube LinkedIn Instagram telegram and all the important links are there in the description okay so session tracker and exercise sheet links are available in the description of the video okay so jumping on to the topic so we are discussing operator in C so yesterday we discussed about few operators and today also we'll be discussing about few more operators so right now we are going to discuss about assignment operator so there are total six operators which are assignment operator and we use these operators frequently so first one is equals to so in programming we have equals to single equals to and we can use it as double equals to also so yesterday I explained you so if I take you here so we can write it like this so if you write it like this so it is double equals to so double equals to is basically for comparison purpose now if you want to assign some value if you want to assign some value so here above you can see a equals to for b equals to 2 c equals to 0 so here this equals to is basically assignment operator okay so if you use it in single single equals to form so it is basically assignment operator and if you write it double time like double equals to so it will be known as comparison operator okay so we need to focus on single equals to today because double equals to I explained you yesterday as well so the single equals to operator is basically assignment operator now we need to understand the working of others like plus equals to minus equals to how they actually works so basically what happens if you write a equals to a plus 4 right if you like if you write this statement so what is happening a is having some value so a is having 4 so 4 will be added to 4 and the result will be assigned into this left hand side a okay so instead of writing this what you can do you can write it like this a plus equals to 4 so this statement a equals to a plus 4 can be written as a plus equals to 4 this is another way to write this statement so sometimes in coding you will see this statement this operator plus equals to so whenever you see a plus equals to 4 you can expand it like this equals to a plus 4 and you can just calculate it okay so similar way if you want to use a equals to a minus let's say b so that you can write like this a minus equals to b right so this way both are both are same if you write a equals to a plus b so this is also okay if you write a equals to a minus equals to b so that is also okay so the catch is if you have a common variable before and after equals to sign so in that case you can write it in short form so this is the catch here right and in Java apex so in those programming also we use these operators right so I hope now multiply equals to divide equals to an modulus equals to these are also same the way I explained you plus and minus right so similarly you can just use these operators right so these are assignment operators and in many programming languages you will be using these operators okay so basically a few people might be like wondering why we need to choose see as our first programming language so the answer is because most of the programming languages built on top of this programming because they they inherited lots of features from this programming language so if you if you understand these basic concepts so you're like other programming languages concepts will be very strong now we have one more operator that is conditional operator and it is very important to understand so now I'm going to show you how we can use it so basically it is for checking the conditions so for example we have two variables and we need to check from those two variables which is having the maximum value right so what I can do I can use conditional operator for that so this way I used conditional operator so here what you can see this a greater than B this a greater than B is basically condition so this is first operand of this conditional operator so here in this conditional operator you can see we have two operators question mark and colon these are two operators and a greater than B then A and B these are three operands right so what is happening here we are trying to check A and B like if A is greater than B so condition will be true if A is not greater than B so condition will be treated as false okay so if it is true so what will happen the value of A will be assigned into C if this condition is true so value of A will be assigned into C if this condition is false so value of B will be assigned into C okay so this way basically it is working so A greater than B is basically condition A is true part and B is false part and you can write print F then max equals to percent D and then C so if you want to display the value of C so it will be the maximum out of A and B so now I'm going to run this code so that we can see the result so here you can see max is four so result is four okay so I hope this code you understood how it is working and if you change the condition like A less than B if I if I change the condition and run the code so now max is two so this is actually calculating minimum right so accordingly you just need to modify this value so right now we need to write min and if I run this code so it will show the minimum so if A is less than B so condition is false so in this case what is assigning B is assigning to C right so this way like whenever you need a conditional statement to be applied so you can use this conditional operator okay so it is also replacement of if else so if you have simple simple condition and you don't want to use if else condition so in that place you can apply this conditional operator okay so I hope you understood if you have any question anytime you you can just ask your question in the chat I will be happy to answer your question but I think these are simple concepts so you are enjoying and now classification of operators so yesterday we discussed four operators four types of operators today till now we discussed two types of operators and here you can see the list of operators classified as unary binary and ternary right so unary means operator will need one operand binary means operator will need two operands and ternary means operator will need three operands so right now we discussed ternary so here you can see this is operand one this is operand two and this is operand three and they are having two operators question mark and colon so basically question mark and colon both work together so that's why it is an ternary category so you can just go through this table so that you can understand how I classified all the operators based on unary binary and ternary and if you have any question you can ask and it is important to remember and I think if you have gone through a different programming languages and you faced challenges so all these operators are there now with the help of these two sessions yesterday and today I hope you are able to understand the meaning of each and every operator that we use basically in programming languages and I hope you are able to relate like why C programming is more important if you want to understand C plus plus Java, Apex or any other programming so C is basically based for that okay so I am back actually there is power cut at my place so that's why I am just turning off the video okay so I was explaining precedence and associativity so I hope now you can listen to me so just confirm am I audible to you please confirm are you able to listen me okay so like there's a power cut so I will be explaining this and yeah power is back so yeah so I was discussing about I was discussing about this precedence and associativity so just a second okay so I was discussing about precedence and associativity so basically in C programming or in any other programming as well we have both the features precedence and associativity so as a beginner you need to understand what precedence is what associativity is so that whenever you are writing the code so you need to know like how I can place the operators and if I need to execute any operator first so what I need to do right so if you go through these statements so each operator in C has its priority or rank when more than one operators are available in an expression then they are evaluated according to their predefined rank right and this is known as precedence of an operator right so I hope with this statement you are able to understand and I am going to show you the table as well yesterday also I showed you that so next is an expression can have more than one operator of the same precedence so if you have more than one operators and their precedence is also same so how you will decide which operator will be evaluated first because in one time one operator will be evaluated so in that case they are evaluated either from left to right or right to left so this is basically known as associativity of an operator okay now everybody needs to understand about precedence and associativity so yesterday I just opened this document for you so on Google you can just search for like operator precedence and associativity so I just searched for that precedence table in C and I just opened any random link and you will find this operator precedence table so here you can see a first precedence will be given to these operators so there are few more operators like when we'll be discussing some difficult or complex topics so you will see these operators so I know you are familiar with plus plus minus minus then on second rank also we have these operators right so there are different operators so now you are able to relate lots of operators few few I didn't discuss because they are related to particular topic so I will be discussing them later on and in third column you can see we have associativity so if operator of same precedence operator of same rank are available in a statement or in an expression so how you will decide which will be evaluated first so for few operators it is left to right for few it is right to left right so you can always take help from this table whenever you are having any complex expression okay and it is it is for all programming so according to that programming language you can just search for the precedence table and then you can decide the sequence like how you you need to arrange and if you if you are not able to decide so what you can do you can use parenthesis so for example if I want to write this kind of statement A plus B multiply C so if I take you to the table so multiplication division and modulus are having higher precedence as compared to plus and minus right so in this expression what will be calculated first so B will be multiplied with C first and the result will be added into A so this is the meaning of precedence multiplication will be performed first and then plus will be performed now your requirement is you need to evaluate plus first so what you can do you can just put a parenthesis so now parenthesis are having a higher priority so now plus will be evaluated and the result will be multiplied with the C so this way you can change the requirement as per the requirement you can change the order of execution so you just need to use a parenthesis for that okay so I hope with this explanation you are able to understand the meaning of precedence and associativity okay now so after this explanation now let's understand some programming concepts so we'll be implementing these four problems for you and as per practice you can also practice these and I already pasted these programs in the exercise sheet so you don't need to note down these because they are already available in the document so you can just practice them directly so we have a problem like we need to swap two variables using third value so let's understand the idea first so we have two variables a and b a is for and b is to now my requirement is if I display the values of a I need to use double quotes here so if I display value of a and value of b so right now what will happen a will display for and b will display to now my requirement is now my requirement is you need to implement the logic in such a way so that if I am displaying a so a should display to and be should display for so this is the meaning of swapping swap means interchange so a is having for be is having to so after swapping what we want we need a should be having to and be should be having for so this is our requirement so we can solve this problem with two different ways so you can have a third variable in place with the help of that third variable you can do swapping okay but let's try without third variable first so I will be explaining you like how you will be thinking so in our mind like first first go in our in first go what will do will be assigning a value of one variable into another so if you assign value of b into a so what will happen b is right now to so be whatever value is having into be so that value will be assigned into a so a will also be having to so a will lose its value that is for and both the variables will be having to to right so I hope you understood this concept if I assign b into a so both will become to to now we need to perform this operation because we need to assign value of b into a but before that what you can do you can have a temporary variable that is C and you can temporarily place the value of a into C so right now C will become four with this statement C will become for the value of a will be assigned into C right now if we perform this so what will happen a will be having to and we we have no worry because we already copied the value of a into C so if a is overridden so that that is not at not at all a problem because value of a is already available with C so we just created a copy of a into C and if a loses its value that doesn't make any problem now what we need to do we need to assign value of a into b but a is equals to be right now and we know we already copied the value of a into C so instead of a what we can do we can assign value of C into B right so this way here B will receive value as four because the current value of C is four and that value will be assigned into B so this way using third variable I interchanged the values now initially a is for B is two but if I use the print a statement so you will see the different results so here you can see a is two and B is four so values are swabbed values are interchanged with the help of this logic so this way I explained you like how you will be building the logic and logic building is same for all the programming languages and C is very easy to understand so that's why if you implement logic building in C so that logic building ability will help you to understand other programming languages as well okay so I hope you are good with this anybody is having any doubt please ask those who are joining this session live please ask questions if you have any doubt I will be happy to explain it again otherwise if you don't have any doubt so just try to solve this swap value of two variables without using third variable so now we don't need to use third variable we have limitation of two variables only because unnecessary we are creating a memory space and we don't want to do that and don't search the solution on internet like we are here I am doing this session so that you can think solutioning of particular problem in a programming way right so these are mathematical problems so you just need to think like how we can solve this okay so I'm assuming you are having no problem with this solution so I'm going to comment it out I'm removing this third variable and here I'm going to write new solution that will be without using third variable okay so first of all I'm writing a equals to a plus b so let's do one thing club both a and b and put that addition into one variable that is a so right now the current value of a will become c sorry six right now with this statement if we add a and b so the current value of a will become six okay so I hope everybody is good till here right I hope everybody is good till here now what we need to do we need to subtract a and b so b is two and a became six so what is happening here six minus two the current value of a is six and the current value of b is two so six minus two so what will assign into b b will be having value as four right so this is the second statement that I showed you the implementation now we need to do this one more time so you need to check the current value so current value of a is six current value of b is four so if I subtract six minus four so the result will be two and that two will be assigned into a so you can see b is having four as a current value a is having two as current value so this is the another logic without using third way okay so now if I execute this code again so let me pick some other values 40 and 20 if I pick these values and click on run so here you can see a is 20b is 40 so you can see the result a is 20b is 40 and initially a is 40b is 20 so with these values you can just test it and initially we were having four and two and if I run this so accordingly you will get the result so a is two and b is four so this way I just showed you how we can swap values using third variable and without using third variable and I hope you understood the concepts and this is the way like you can just write comments if you have complex logic and you can use paper pen or you can think in your mind so these are the ways like you can try and implement the logic so this is actually known as dry testing so you just need to test the code line by line and just just note down if you execute a particular line so what is happening just record the results somewhere and then you can just start understanding other lines right so I hope you are good till here if you have any questions so far you can ask I would be happy to help you and those who are watching the recording if you have any doubt you can just ask in the comment section or like in the beginning of the session I shared one QR code so you can just join that telegram group and anytime like if you see any problem so you can ask questions okay so I just explained you two examples now we have two more which are also simple and kind of related and in these examples you will get to know the use of divide and modulus operators right you will be understanding the use of divide and modulus operator which are basically arithmetic operators right so I'm going to explain you those so first requirement like number three is reader two digit number we need to have a two digit number and we need to print some of it it's individual digits so what I'm going to do I just removed everything now here I have a variable I am naming it as num and it is 23 so as per the question it is mentioned read a two digit number so you need to read one two digit number or you need to have one two digit number you don't need two different numbers it is one number having two digits so you can have any number between 10 to 99 because only those numbers are having two digits so we have a number which is having a value that is 23 so 23 is having two digits but it is one number okay now what we need to do we need to print some of its individual digits so 23 is having two digits two three so what we need to show as output it should be five so we need to add two and three so if we add two plus three so result will be five now we need to see like how we can do that okay we need to understand the logic so I will be using two operators one is divide and one is modulus okay so I'm creating one more variable a then I'm writing a equals to num divided by hundred and so this divide operator gives quotient so if you use this divide operator so it will give you the quotient value so those who are joined live can you tell me what will be the value in a variable if you perform this operation num by 10 so what do you expect like what will be the value in a yeah so Mohan Mike is very close to me so I hope you are able to listen so just check your laptop settings as well so my question is if we have this statement num by 10 so what will be the value into a and we have a data type in so just just paste your question sorry paste your answer in the chat so Nikhil said to I need more responses Mahima is saying three I need more responses you can focus on this comment like divide means it will give you the quotient so Mahima I need I would say like you need to think again about your response because it will give you the quotient value so number is 23 so it will be divided two times so a will be having two not three right so value of a will be two okay now I'm writing one more statement so I'm taking one more variable be so I'm writing num modulus 10 right so you need to tell the value of B what should be the value of B and this modulus operator gives remainder value okay so everybody tell me the answer of B like what should be in B so those who have joined life please respond so that I can check like did you understand correctly or not so num is still 23 this time we have applied modulus so what should be the result yes Mahima this time you are right so this time B will be having value as three right Nikhil your answer is also correct so now a is having two B is having three so we kind of splitted the number right so what we need to do we need to print some if we read the requirement so it says print some of its individual digits so here what you can do you can write print F then sum equals to percent D and here you can write a plus B so a is having two B is having three so there's some will be five so this way some five will be available as output so if I click on run so you will see some equals to five so I hope with this way you are able to understand like how I was able to build the logic okay and in upcoming session like tomorrow maybe we'll see how we can do it for three digit number four digit number and then I will tell you in one of the session like how we can solve it for any number of digits like you have two digit number that code will run if you have three digit number the same code will run so for that we'll be understanding loop so I hope this example you understood very well and if you have any question you can ask and if you are watching the recording still you have any doubt so you have two options just comment in this video and you can join the telegram group whose QR code is available in the beginning of the session and if you have understood this now we can jump on to the next requirement which says read a two digit number and print its reverse so this I pass to you those who are live joining the session please try to solve this we have a two digit number now we need to print reverse of it so if number is 23 so the outcome should be 32 so most of the code will be same we just need to change little bit so if if you guys can help me out so I would be happy so let me know like we just need to change here a plus b will be replaced with an expression so what that expression should be so that we can have reverse of the number so please think and answer your paste your answer in the chat so that I can see the results so like I hope you understood the question so we have 23 we just need to display 32 and we already splitted two and three separately so now you need to create an expression yes Mahima your answer is correct it should be B into 10 plus a so B is having three so what we can do we can write B into 10 plus a right and if I execute this code so you will see 32 so instead of some what I can write reverse and let's take any other number so let's say 45 so it will it will show 54 here you can see reverse is 54 okay so this way this is a generic code for two digit only this is a generic code for two digit only and nickel nickel also pasted so that is also correct Rajiv your answer is also correct and nickel I think here we don't need to use parenthesis because we need multiplication first and as per precedence it will happen first but still if you have used so that is also okay so I hope you understood and do practice at your own and I have created this exercise sheet so day by day I will keep updating this and tomorrow tomorrow we will be understanding few more problems I will be adding few more examples here so tomorrow's session will be like solving problems okay and from next week we will be starting conditional statement like more complicated problems will be there so that you can understand those okay so with this note I just end today's session till like here only and pass this information to more folks those who are interested to learn programming that to free of cost and I am explaining each and everything in detail so that you can understand the concepts so for beginners these C and C++ bootcamp is very much important so I can see like people are watching recording as well and they are asking questions so please spread the information with the community so that more and more folks can join the sessions and understand the concepts okay so this is all for today thank you so much for joining this session and do join tomorrow's session as well because tomorrow I will be explaining lots of problems so that you can understand them thank you for joining today's session see you tomorrow bye take care