 Welcome to this video lecture. In this video lecture, we shall be discussing how we use loops in C language to solve a particular problem by writing a C program for it. So at the end of this session, this is the learning outcome that you will be able to solve a problem by writing a C program using loops. So we shall use different types of loops and see how looping will help us to solve a particular problem. So these are the links for video lectures of for loop and nested loop and while loop the playlist is available at the right side of this video. So you can go through the playlist and if you are not well versed with any of the concept, then you can go through the video and get yourself trained so that you will be able to be so that you are in a position to solve this problem that we are going to discuss. Now consider that you are given an array of integers where all the given integers except one occur exactly two times in the array. Okay, so there is an array of integers where there is one unique element and all the others elements are occurring twice. The unique array, the unique element in the array is to be found out and printed. So if you have understood the problem statement, the input will be the first line will be the number of input elements that we are going to take that is the size n and the second line will be the n number of separated integers describing the values in the array. Now the input you can store it in the integer or process the input one by one. We shall see it in detail in the video and the output will be the unique integer from the array. Say for example, I have passed three as the value of n and the elements that are separated by space are one space two and space two. So here I can see that one is the unique element and two is repeated twice so one will be returned by the output as the output. So what is the algorithm to solve this particular problem? First we take the input size as n from the user then I am going to require a variable result and this will be initialized to zero. The reason that we initialized to zero will be explained later as we see how to solve the problem. Then I will read or the program reads n elements and one by one the elements will be read. Say for example, we are reading the element and storing it in A. For every element that is read what we do is we perform x or operation along with the previous result and then store it in result and finally when all the n elements are read and processed with the x or operation we print the result. This is the algorithm. Now before we go ahead and solve the particular problem I want to discuss with you the nature and behavior of x or operation. So this is the truth table of bitwise x or operation. Now we can notice that if A and B that is the both the inputs are same the operation will always return to zero. This happens in the first and the last case but we see that if the inputs are different or either of the input is zero then the other input results as the output. This is explained in detail here at the left hand side. We can see if both the inputs are same then the x or operation leads to zero output. This happens when any binary or decimal number is operated upon. If I operate five x or five the result will be zero. Similarly if I operate x or operation and either of the operator is zero the result will be the other input. So I can see here A x or zero will return A or five x or zero will return five. So say for example I have three inputs as we took in the last example B x or A x or B. Now we should remember that x or operation also follows commutative and associative property. So by the property of by the commutative property it will be it can be written as B x or bracket B x or A and by the association just to cancel out the common elements what I can do is B and B can be associated together which will turn into a zero later and just the unique element or A will be returned remain. So zero x or A at the last step gives a result as A and this is the way that we are going to use x or to get the unique element. Now this is the program that I have written first I take the number of elements or the number of input elements that I am going to require store it in n and while n is greater than zero that is while the while n is positive and we have elements remaining to be processed I am going to scan the array scan the element excuse me store it in A and I am going to x or it with the result variable. We shall see the output of this program say for example I have three elements and the elements are five six and five so we can see that five has been repeated twice whereas six is a unique element and my program is returning six which is the correct output. So this is the program this program is available for freely to be downloaded in the description section you can refer to the description section for the link of this program. Now moving ahead right now I want you to stop and pause the video and use for loop instead of while loop to solve the same problem. So I have used a for loop instead of while loop to write down the solution for the same problem. So instead of writing of while loop I have written a for loop which starts from i equals zero and it runs till i is less than n. So what I do is I simply scan a particular value in variable A and do the same x or operation that we have discussed which yields me the correct answer say for example once again when I am executing this problem I have three variables one two and two and according to our logic it should return one which it successfully does. So this is how we find a unique element in an in an array of elements which has which has every element twice but only one element as a unique element. So these are the references this is the reference to the problem statement from hacker rank if you need further clarification of the use of xor operator you can follow this link and there is also a theoretical reference to loops in C. Thank you.