 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to explain a program based on C which will calculate a maximum number from and input numbers, right? So before starting, if you go to the description or detail of this video, you will find links of various playlists so you can watch them too. So now, first I'm going to explain what is the logic behind this program and then I will implement the program. So let's say there is a program we need to find, we need to find maximum and we have n students, we have n students. So let's say first time you execute the program and you have five students in a particular class, then second time again you execute the program and that time you have 10 students, right? So every time whenever you will be executing the program, you have different set of students. Now, so this will be your first input. So we can say it as input number one, like how many students are there. So after receiving that input, we are going to implement a loop. So in this case, five loop will be repeating five times. In the case of 10 students, loop will be repeating 10 times. So loop will depend upon the value and right after repeating that loop inside that loop, we need to read marks inside that loop. We need to read marks. So in this case, when five students are there, so inside loop, we are going to read five individual marks and from those marks we need to identify the maximum. And here we need to iterate the loop 10 times. So loop will be leading 10 different marks and will be finding the maximum. So this way there will be two inputs. So this will be input number two. So first we will read how many students are there and then we will implement the loop and inside that loop we will be mass of students and find out maximum. So now I'm going to implement the C program to fulfill this requirement. So I am taking one variable as N which will read how many students are there. Then I will be using one variable I for loop counter, then variable max whose initial value is 0 and one variable has marks which will be leading individual marks of the students. Now first printup. So it will display a message how many students. So we need to read how many students are there so that we can identify maximum from those marks. So here I am reading number of students inside N variable. So N is having quantity like these many students are there. Now after this I can apply a loop which will start from one. It will repeat 10 times. So I started from one, it will repeat 10 times and I plus plus will increase it by one every time. So now inside this loop I need to read the marks of students that is input two. So we know how many students are there because of this N variable. So let's say N is 5. So this loop will repeat 5 times. So every time it will be reading a particular marks and then inside the loop we have to identify whether that input marks is greater than previous inputs or not. So let's see how we can do that. So this way this message will be displayed enter marks or you can say enter mark because we are going to read one by one. Then scan of 470 and percent marks. So first student marks will be stored inside this variable. Now here you can see we have one variable max. Now after scan of you can apply if condition and you can write if marks greater than max. If marks is greater than max then you need to assign max equals to give it to assign max equals to marks. So if marks value is greater than this max variable then marks will be assigned into max. So this will become the correct maximum and here I am closing this form and after completion of this form you can print maximum equals to 470 and here you can print max. So max variable will be having the maximum value that is maximum marks among 5 students or among N students. So this is a complete implementation. Now I am going to tell you how it will work. So line by line I am going to execute this so that you can understand it. So initially you can see marks value is 0. So I am writing it here. Marks is 0 and let's say we entered NS5. We need to identify maximum from 5 students. So NS5 max is 0 and till here we have executed the statements. Now we are iterating this loop. So this loop will repeat 5 times. Now first time we will display enter mark. So we will enter particular marks in this marks variable. So let's say I entered 50. Let's say I entered 50. So this 50 will be assigned into marks variable. Now check this condition marks greater than 50. So it is true. Marks is greater than max. So marks will be assigned into max. So new value of max will be 50. So till now maximum marks is 50. Now again I will be incremented. So initially I was 1. Now value of 5 will be 2. So it is repeating second time. So again it will ask enter mark. So let's say this time I entered 70. So now marks new value is 70. So check this condition marks is 70 and max is 50. So again it is true. So marks will be assigned into max again. So max will become now 7. So till now we have entered 2 students marks and maximum is 70. Again I will be incremented. So this time let's say value of 5 is 3. Again we need to provide marks. So this time I am entering 20. So check this condition marks greater than max. So marks is 20, max is 70. So it is false. So it means this if will not perform. So this assignment will not perform and loop counter will increase by 1 and it will move to 4. So you can see we have entered 3 students marks 50, 70 and 20 and right now max is 70. So if input marks is greater than max then only those marks will be assigned into max. Otherwise the rotation will go to max iteration. So after 20 let's say I entered 100. So this time marks is having 100. So 100 greater than max. Max is 70. So it is true. So 100 will be assigned to max. Next time suppose again I entered 100. So here you can see I have used greater than sign only. So 100 greater than 100. So this condition will be false. So this 100 will not be assigned into max because max is already having 100. So this way we can iterate this loop and we can identify the maximum value. After completion of this loop you can see printf is printing maximum equals to percenty. And this max variable value will be printed in place of this percenty. So right now max is 100. So we provided these 5 marks and out of these 100 is the maximum. So which will be displayed on output 2. So I hope you understood how we can identify a maximum value among n numbers with the help of loop. I didn't implement any array in this case. I just iterated a loop and through that loop I am able to identify which value is maximum among n input numbers. So I hope you understood how I implemented this. I just want to do one change in this. So let's say you want to print enter marks of first student enter marks of second student. So you can modify this printf like this. Enter first student marks and then here you can write I plus 1. So here you can see I is 1. So this I will be printed here. So it will print enter first student marks. Then next time I will be implemented. So I will become 2. So it will print enter second student marks. So here you can use I variable that will be this percenty. So this way also you can modify this printf. So I hope you understood how we can find out maximum from n input numbers with the help of loop. And this program is implemented in C. So you can implement it in C components and you can execute whether it is working fine or not. So I hope you understood whatever I explained in this video. If you want to watch more programming related videos, you can open my channel go to playlist and there you will find more than 1000 programming related videos. So do watch them. Thank you for watching this video.