C_13 Operators in C - Part 1 | Unary , Binary and Ternary Operators in C | C programming Tutorials

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in the series of learning programming in c in previous lecture i have discussed character data type means we are done with all the data types we have discussed all data types now from this lecture i am going to start operators in c we will be discussing every operator every type of operator in detail with proper examples or you can say with programs like i'll show you how to use that operator when to use that operator and in programs i'll show you and what you will get output right what output you will get if you are using that operator so in this video i'm going to start with basics like what is operator and um how to classify operators means operators can be classified into you know based on two categories like based on operations and based on uh that operands so that thing i am going to discuss in this video and this video is brought to you by an academy on an academy multiple batches are going on for csir ugc net june 2021 so if you are planning to prepare if you are planning to appear for csir net exam in june 2021 you can go for it they are going to cover the complete syllabus and one batch is going to be started from 8th of january that is for life sciences in this batch their best faculties will cover the entire syllabus for life sciences for csir net june 2021 exam and this batch the classes in dispatch classes would be conducted in hindi and they'll also provide you notes and the content they'll provide the notes they'll provide you in english language right and this is you can say the paid subscription because they are going to cover the entire syllabus you will get complete course a structured course and if you use the code jkl10 you will get 10 discount on your paid subscription so if you are interested you can go for it all the details and the link as well as the referral code i'll put in the description box of this video you can go and check out you just have to download an academy app and you have to get the subscription of that course right now let us discuss what are operators see operator is it's you can say just a symbol which tells the compiler or which tells the computer which operation has to perform on the data or you can say which tells the computer which mathematical or you can say logical manipulation is to be done like many operators are there plus minus divide logical and logical or relational operators many operators are there so let us take this example this is what an operator it is a symbol so it is going to tell the compiler that it has to perform plus operation plus operation means if you will give the value 1 and 2 then output would be 3 and if you write here minus it means compiler will come to know that it has to perform minus that minus operation or based on these data given this data is what this is what operands this is what operator now you can say operator is what operators are basically used to manipulate you can say variables or data in c language i'm going to discuss all the operators in the context of c language only right and with the help of operators variables and constant or you can say with the help of operators and operands in expression is to be formed so you can say what expression is a sequence of operators and operands which gives a single value after processing suppose i am taking like this a is equal to 5 plus 5 so this is what an expression here 5 5 these are what operands plus and equal to this is operator a is what variable and after processing it will give single value so after processing it will give what 10 that would be assigned to this variable so this is what an expression right now types of operators types of operators based on operands and types of operators based on operations two categories are there so here i am going to discuss types of operators based on operands number of operands so there are three categories three types unity next one is binary and ternary operator unary means only one operand is there binary means two operands ten array means three operands now what are these unary operators this is unary minus see this minus is different from binary minus here also we have plus minus that is minus this is unity minus this is binary what is the difference that is we will see also this is unity minus unary minus increment decrement operator logical not operator this is logical not this is address of operator and this is size of operator so these operators required only one operand only one operand now what is this unary minus it is going to change the value means if positive value then it is going to change that value to negative if negative then positive suppose i am writing here uh like in a and b and i am taking a is equal to if you write like this a value 5 b value 10 and c is equal to a plus b but here we have used unity minus operator it means the value of this is not 10 this is minus 10 and this is what 5 so output would be minus 5 right and if you write like this a is equal to suppose i am writing here minus b b is what 10 but this is preceded by minus sign unary minus so that that is minus 10 and this value would be assigned to variable a now a will becomes minus 10 so this is different from that binary minus operator right next is increment and decrement operator this increment and decrement operator we can use in two ah types in two cases prefix and postfix suppose i am writing here x plus plus or plus plus x so this is what this is also increment operator this is increment operator but here this is postfix and this is prefix because i am writing this one after variable means post before variable means pre and the result is also different it's not like that this will give save this and this will give same result see if you are writing here this one x plus plus and suppose here i am writing see x plus plus means here x plus 1 x is equal to x plus 1 right now this is what after this variable means postfix so the value of this x would be altered after the execution of this line y is 10 here space would be allocated to y 10 one variable is x memory allocation 11 would be stored here now i am writing y is equal to x plus plus so now in y what would be store you will say x plus plus means 11 plus 1 12 would be stored here no but here 11 would be stored because this is post first value see you can say right after equal to we have x x value is 11 11 would be stored here and plus plus s after this variable so after execution of this statement now x value will be 12 but y is 11 so output of y is 11 now output of this is 12 i hope you got my point and if you write here plus plus x here the value of x would be altered before execution of this line now here here x becomes 11 is equal to 12 and here it will be stored 12 right here also we have now plus plus x means x is also updated that is 12 now y value would be 12 and x value would be 12. because here plus plus is before this x so first of all x would be incremented that would be stored in y right so that is why the y output is 12 and same minus minus is what minus minus means minus minus x x minus minus this is pre this is post it means also x uh what x minus 1 and x minus 1 right same rule will be applied in minus minus also as in plus plus right now we'll be discussing these operators in detail one by one in separate video this is just an overview i hope you got my point what is plus plus and what is minus minus here plus plus it is taking only one operand that is why it is unary operator this is also taking only one operand only x right next is logical not it is it is going to convert true value into force and false value into true it is going to i know reserve this logical state of any operand now suppose if i am writing here suppose this condition and x and y value are this one so x is 11 greater than y 10 11 is greater than 10 this is true but you have used logical not it means it will return false right now if suppose i am writing here y greater than x so here y is equal to 10 greater than x 11 is 10 greater than 11 no so this expression will give what false value but you have use logical not that is why it will give true i hope you got why this logical not what does that mean right next is address of operator it is going to retrieve the receive or you can say fetch the address of any operand from memory this operand we will use in scanner function we generally use or when we will use pointers at that time this operator we are going to use next is sizeof will give you can say size of whatever value you you are given here whatever data type suppose you are giving a data type here size of int and if you want to print this one so it will give 2 bytes or maybe 4 bytes size of float it will give 4 bytes it will give size and bytes memory size in bytes so it is used to find out the size of any data type or it is also you can also use it with a variable also here you can also write any variable if you are writing here like suppose int a and you can find out size of a that will give a is what type is what integer so it will give size 2 bytes right so all these operators we are using with only single operand that is why these are known as unary operators next is binary operators here we are going to use two operands like in plus minus divide many type of binary operators are there just let me just write down the list here so these are some binary operators we are going to perform these operators on two operands arithmetic all the plus minus divide into and that modulo relational less than equal to less than equal to greater than equal to logical and logical or bitwise operator bitwise end bitwise or left shift right shift bitwise xor and bitwise negation equality operator also and not equal operator also this you can include in relational also if you are not specifying it uh separately comma operator assignment operator also so all these operators one by one we are going to discuss in detail in separate videos because this video would be lengthy if i am going to discuss these operators right next is what ternary operator ternary means it requires three operands it is also known as conditional operator so here we are using this question mark and these columns now how the syntax of using ternary operator is what here we are writing some expression expression means you can say sequence of operands and operators that after processing give a single result so if expression after the processing of expression 1 if expression 1 is true first first would be what condition first expression should be a condition here that is a rule so now if this expression one if this condition is true then this one this expression would be evaluated and it will give you result whatever result you will get after evaluating expression 2 that would be output if expression 1 is false then control will go in expression 3 this expression would be evaluated and it will give you the result let us take one example uh if i am writing here this is suppose an example a value is 10 b value is 15 so now this is expression 1 this is second this is third first of all this expression would be evaluated some rules are for this for some rules are there the first expression must be a condition second rule is either this expression 2 or this only one either this or this would be evaluated based on the value of expression one it is not that both would be evaluated only one and this must be a condition so here a is ten and b is fifteen ten greater than 15 is it true or false it is false so now this expression control will go here at b now b value is what 15 so in x what value would be store 15 if you will print printf this x then 15 would be the output right and suppose if you write here a less than b now is it true yes it is true now the control will go to a this expression would be evaluated here we do not have any expression we just have any of an operand that is a value is 10 so now 10 would be assigned to x and output would be 10. so this is what ternary operator or you can say condition you can use a ternary operator to form a conditional expression and you can use this one conditional expression conditional operator in place of effects because if else also you can convert it into if if else this statement if a less than b you can say x is equal to a and else x is equal to b that's it if a is less than b means if this is true then a value would be assigned same if this is true then a is going to be performed and if this is false then control will go here and this expression is going to be evaluated same here meaning of this and if else statement is same so you can use this conditional operator this statement rather than if else if else we will we are going to discuss in later videos in detail right so that's it about types of operator based on operands uh i hope you go to all these operators if you want me to make a separate video on the stunner operator in more detail then you can tell me in the comment box so in next video i'm going to discuss types of operator based on operations so now i'll see you in the next video till then bye bye take care
Info
Channel: Jenny's lectures CS/IT NET&JRF
Views: 64,467
Rating: 4.9068055 out of 5
Keywords: data structure tutorials, operating system, data structure and algorithms, jayanti khatri lamba, jennys lectures, jenny data structures, jennys lectures DS, jenny lamba, jennys baby, jennys lectures baby, data structures, operators in C, c programming language, youtube channel C language, C++, jennys C lectures, jenny lecture, jenny c classes, jenny c youtube, jenny data structure youtube
Id: E1_Gg6dURwk
Channel Id: undefined
Length: 15min 38sec (938 seconds)
Published: Wed Dec 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.