 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print some of first and last element, second and second last element and so on which are available in array. Before starting, you can note my information. You can follow or subscribe my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can download my programming app that is Techimps which is available on Google Play. Now coming on to the program for solution, I am first including a header file. Then inside main function, I am declaring an array, sizes 10, then variable i and a. Now I am implementing printf which will display a message, enter elements on console. Then I am implementing for loop which will repeat 10 times and this loop will repeat scanner statement. This scanner will read 10 elements and all these 10 elements will be stored inside a array at different locations. Now I have to implement the logic so that I can add first element of array with last element, second element of array with second last element and so on. So for that purpose, I have to begin two indexes. So I am initializing two variables i from 0 and j with 9. So i is initialized with 0 and j is initialized with 9. Condition is i less than equals to j. Then i plus plus comma j minus minus. So this is the first header of loop. Here you can see i is starting from 0. So it will point first location of the array. J is starting from 9. So it will point to the last location of array. Condition is i less than equals to j. So if i is equal, i is less than or equals to j, then this condition will be true. So loop will be repeated. Otherwise it will be false. Then i plus plus and j minus minus. Now I am going to implement printup statement. It will print addition. So I am applying a of i plus a of j. So a of i is pointing to first location and a of j is pointing to last location. So the addition will be printed on console. Then i will be incremented by one. So it will become one and j will be decremented by one. So it will become eight. So one and eight index values will be added further. So with the help of this for loop, all the additions starting from first and last location will be displayed on console. Then return 0. Now I am going to execute this code. You can see it is asking for 10 numbers. So I am entering 1, 2, 3, 4, and 5, 4, 3, 2, 1. You can see the output. First one and last one is added. So result is 2. Then second element is 2 and second last element is 2. So result is 4. Then third element and third last element 3, 3, so 6, then 8 and 10. So you can see all the additions are displayed here and here number of elements are 10. So it is working for even numbers. Well, now I am increasing the size of array. It is 11 now. So this time I am going to show you whether it is working for all quantities of odd numbers or not. So previously total number of elements was 10. Now total number of elements are 11. So this i less than equals to j will print the correct result because if 11 elements are available, then the middle element will be added by itself. Again, I am executing this code. You can see the input. I have entered 11 elements. So 1 and 1, 2, then second element is 2 and second last element is 2. So 4, then 6, 8, 10 and middle element is 6. You can count 1, 2, 3, 4, 5, then 6 element is 6 and remaining 5 elements are 5, 4, 3, 2, 1. So 6 element is added with itself. That's why it is printing 12. So friends, if you are entering even quantity of numbers, then this loop is working properly. And if you are entering odd numbers of elements, then also it is working properly. So I hope you have understood how we can add initial and ending elements of array together. If you want to watch more programming related videos, you can follow my YouTube channel through the URL youtube.com slash sanjaygupta underscore tech school. You can also download my Android app that is TechMS which is available on Google Play. So keep connected with me and learn programming because learning programming is very easy. Thank you for watching this video.