+ 1
Why i am not getting right results in this questions??
https://code.sololearn.com/co4Z7ouIhfK6/?ref=app https://code.sololearn.com/cSZyu1U1U3s8/?ref=app https://code.sololearn.com/cvqS5QH2235Q/?ref=app
5 Respuestas
+ 1
In all programs..
Reset store = 0 ; after inner loop.
And print prime I after inner loop. Not inside inner loop..
Hope it helps..
+ 1
Jayakrishna🇮🇳 sir thank you once again for helping me 😊. Sir may you please me reson behind doing this two things, how changes results ?
+ 1
Jayakrishna🇮🇳 yes sir . Thanks . I get it 😄😊
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...
0
You're welcome..