 Hello and welcome to this video lecture. In this video lecture we shall solve another problem using the loop constructs in C and we shall see how to use the loops and if condition to solve a particular problem. The objective of these video lectures is help students to prepare for competitive programming competitions. So the learning outcome for this video lecture is at the end you will be able to solve a problem by writing a C program which takes the help of loops and if condition. So these are the videos that are already present in the playlist that you can see alongside. So if you are not very well versed with for loops nested loops and if condition and if else condition you can go and click to these links and go and acquaint yourself with these concepts so that it will be easier for you to solve the problem that we are going to discuss. So what exactly is the problem that we are going to see or solve in this video lecture. You are given n inputs and two numbers x and y. Our job is to check whether all the given numbers lie in the range of x and y where x is less than equal to y. So in short we are given a set of numbers and we have to and two boundary cases one is the lower boundary which is x and the other is y which is the higher boundary and we have to check whether all the given numbers lie within this range of x and y. So if the condition is true I mean if all the numbers fall in this range we print yes if it is false we print no. For instance say for example I take three numbers that means the set of numbers is three and hundred is the lower limit and two hundred is the upper limit so 99 falls out of the range because hundred is the lower limit 102 and 178 of course they fall in the range but the input sorry the output here is no since 99 falls out of the range. Similarly here we have five numbers that we are going to consider and zero is the lower limit and hundred is the upper limit x and y respectively and one two three four and five fall in the range from zero to hundred. So we print yes because it is satisfying the upper limit as well as the lower limit. So what process should we follow or what should be our approach to solve the problem. So the algorithm is nothing but the process the set of steps that we are going to follow to solve the problem. After initialization we input three values from the user we take the input for three values one is the number of elements that is n the other is the lower limit that is x and the other is the higher limit that is the upper limit y and we are going to also take another variable and call it as count and then we are going to take the input of n values starting from zero to n minus one and we are going to store it in the array say for example a after taking the input from the user for n elements we are required to scan the array. Now the scanning means we are going to traverse all the elements in the array right from zero till we come to n minus one index now we you might be knowing that and the array is traversed from zero one two three till we reach n minus one that is if we are have if the array size is five so we can traverse right from zero till four. So in these elements from zero to n minus one if the element is greater than equal to x and if the element at particular ith location if it is less than equal to y that means if both the conditions are fulfilled we increment the count variable by one that means we are going ahead to traverse the next element in case if this condition does not satisfy or this condition returns false we print no. So we are going to scan the entire array and just consider that none of the elements fall out of these two boundary cases that means they are greater than x and less than y if all the elements satisfy this condition we will the program will come to a point that the count will be equivalent to n that means all the elements are greater than x and less than or equal greater than or equal to x and less than or equal to y if this is the case and we have come to the end of the array we print yes and then stop we shall now see to the code implementation of this particular problem using C programming language. So this is code blocks IDE I highly recommend all students to use this code blocks IDE because it is freely available and it helps to keep your code combined together in a single in a single project so that if you are developing huge projects having a lot many C files that you can store it all together and this is the code that I have written I have declared into array of a thousand elements and these are the variables that I am going to require as I have mentioned earlier count is initialized to zero variable count I am going to require i and n for a number of elements that I need to require x is the lower limit y is the higher limit I take the input for the number of elements that I am going to require and x and y are the lower limit and higher limit respectively now I am going to scan scan the entire array from zero to n minus one I have not mentioned n minus one because when i is less than n the loop will run only from zero to n minus one so I am going to scan every element for n times yes for n times and here I am going to make the comparison that is if the element that is entered by the user if it is greater than or equal to x that is the lower limit and if the element entered by the user if it is less than or equal to y then increment count then increment count else if this condition returns false or if if this condition is not satisfied straight away we print no and return zero that means we end our function here itself by returning zero and we print no if we reach to the end of the array where count will be equivalent to n the value of count will be equivalent to n we print we print yes and then conclude with our program I will show you the demonstration of the of this code this code is available in the description section you can click the link and you will get the code that I am executing here which I'll see the execution of this code first is the number of elements say for example I have three elements the lower limit is 100 the upper limit is 200 and now I am expecting the user to enter the enter the elements I will enter the elements now 125 first element 150 is the second element and say 199 is the third element so it should return yes let's see what our program returns it is returning yes let's execute it for one one more time say for example I have four elements and the boundary is zero to say 10 and I need to put up four values say for example I put up 20 so it is immediately it is returning no because it does not accept it and the first element itself is out of the boundary case so this is the implementation as I mentioned earlier you can refer to the description section for this code this point in time I want you to pause the video and write down the code for the same problem but in this code in this program I want you to use while loop instead of for loop pause the video and try to write the code so we shall discuss how to write the code using the while loop for using while loop instead of for loop what I have done is I have initialized variable I equals zero now I am going to use I as the counter variable just for the ease of your understanding and I am going to run the entire while loop until I is equal to n so that so that the while loop will run till I is less than n and it will stop running when it becomes equal to n for this you have to take care that when you have initialized it with zero after every comparison you have to increment I by one so we start with I equals zero and we check for the condition while I is less than n we run the entire while loop and after at every iteration we are incrementing I by one rest of the lines remain the same so we shall check for the execution say for example I have three values to check and the upper the lower limit is 100 the upper limit is 200 so if I say for example I enter 125 and 500 say for example and hit enter it will give me no because 500 does not lie within the range of 100 and 200 so these are the references that I have referred to you may also refer to these references for for in-depth explanation and for other problems that you can solve using loops and if condition thank you