I have made a program of prime number. I want to know did i initialized the class member c=0 correctly or not. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have made a program of prime number. I want to know did i initialized the class member c=0 correctly or not.

https://code.sololearn.com/cUS1pqQZ5aG6/?ref=app

23rd Feb 2020, 6:59 AM
Disha Dey
Disha Dey - avatar
2 Answers
0
Since it is declared outside the function, it is fine.
23rd Feb 2020, 7:12 AM
Avinesh
Avinesh - avatar
0
Its perfect since c was initialized inside the function and befor the 'for' loop. Evry time when call display(), must renitialize to start count divisor from 1 by c increment.
23rd Feb 2020, 8:45 AM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar