5 Answers
+ 1
In all programs.. Reset store = 0 ; after inner loop. And print prime I after inner loop. Not inside inner loop.. Hope it helps..
10th May 2022, 6:54 PM
Jayakrishna 🇮🇳
+ 1
Jayakrishna🇮🇳 sir thank you once again for helping me 😊. Sir may you please me reson behind doing this two things, how changes results ?
10th May 2022, 7:01 PM
Abhay mishra
Abhay mishra - avatar
+ 1
Jayakrishna🇮🇳 yes sir . Thanks . I get it 😄😊
10th May 2022, 7:33 PM
Abhay mishra
Abhay mishra - avatar
0
Your first loop works for i= 1 to N Inner loop j=1 to i checks factors for i. After the loop, you have number of factors in store variables. Now you need to check store==2 or not. If you check this inside loop.. It prints I when store == 2 but you can get more factors for i next. So must first complete factors. Check after loop. Now you checked about i for example 2, and store=2, prints 2 Next i=3 , now you repeat same process for I=3,... without reset store, you starts store=2, after loop store becomes 4,.. It keep on increases for next values but, your condition store==2 never met again. So it only print 2 but not any value, without reset store=0; Hope it helps to understand...
10th May 2022, 7:29 PM
Jayakrishna 🇮🇳
0
You're welcome..
10th May 2022, 7:36 PM
Jayakrishna 🇮🇳