 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can print the list of prime numbers which are available in array. Before starting, you can note my information, you can follow or subscribe my YouTube channel through this URL youtube.com slash sanjaygupta underscore tax school. You can download my programming app Takamis which is available on Google Play. Now coming on to the topic, in this video I will be demonstrating you how you can print the list of prime numbers which are available in array. For that purpose, first I am including a header file that is stdn.h then inside main function I am going to implement an array. Size is 10 then i, j and a variable f which will be used for flag then I am using printf which will display the masses. Enter elements on console then for loop this for loop will repeat scanner statements so that 10 elements can be received and all the elements will be stored inside array a. So with the help of this for loop all the elements will be received and all the elements will be stored at different indexes which are available inside array. Now I am going to implement the concept of nested loop so that I can print the list of prime numbers which are available in the array. So first I am implementing a loop starting from 0 it will repeat 10 times because adding is containing 10 numbers. I am again declaring a variable n so here I am assigning a of i into n so n will be receiving first element of array then I am initializing f with 0 then I am implementing for loop j equals to 2 j less than n and j plus plus so this is the condition of prime number because prime number the number which is prime it is divisible by 1 and itself that's why I am starting loop from 2 and it is repeating less than n times so n is containing the element which is available inside array so suppose a of 0 index is containing a number 11 so n will be receiving 11 loop will start from 2 and it will repeat till 10 so from 2 to 10 all the numbers will be available for the division so that we can check whether the number is prime or not so inside this loop I am going to implement if condition n modulus j w equals to 0 so I am trying to divide n with j if it is divisible then I am changing the value of f to 1 and I am breaking the loop so this is the j loop which is checking whether the number is prime or not so here n is divisible by j if it is completely divisible then f will become 1 and loop will be terminated so after this loop I have to check the value of f so if f w equals to 0 it means this if condition is false all the times and if this if condition is true then only f will be containing 1 so if this condition is true that is f w equals to 0 then I can print percent d is prime and I am printing value of n so this way you can see I have implemented the complete code at last I am writing return 0 so here you can see n is receiving a number then f is initialized with 0 every time whenever this j loop will be beginning j is checking whether the number is divisible by j or not if it is divisible then f will become 1 otherwise it will remain 0 so if f is 0 after completion of j loop then I can print number which is available inside n variable that it is prime and then I will be incremented and another value of array will be assigned into n for checking so this way all 10 elements which are available in array will be checked and those numbers which are prime will be displayed on console now I am executing this code you can see it is asking for 10 elements so I am entering 11 12 13 14 15 16 17 18 19 and 20 you can see the list 11 is prime 13 is prime 17 is prime and 19 is prime so 12 14 16 18 and 20 all six numbers are not prime and 11 13 17 and 19 are prime numbers if you want to display these results on separate lines you can apply slash and here so again I am executing this code again I am entering 10 numbers you can see the result 11 13 17 and 19 are prime and other elements are not prime so four numbers are prime out of these 10 numbers and six numbers 12 14 15 16 18 and 20 are not prime so this way I have checked all the elements which are available inside array and the and only those numbers which are prime are displayed on console and remaining elements are not displayed so this way I hope you have understood how you can check which element is prime available in array or which are not prime which are available inside array if you want to watch more programming related videos you can follow my youtube channel through the URL that is youtube.com slash sanjay gupta underscore you can also download my programming app Techimus which is available on google play so keep connected with me learn programming because programming is very easy thank you for watching this video