0

I want some help with dynamic arrays in CđŸ„ș

In 22nd line of my code, I used an array to store all the factors of a number which is of type long int. We all know that the number of factors of a number is variable as it's dependent on the number. Is there anything I can do to optimize my code? I imagine something as an array with initially of one length of type long int, and gets bigger automatically when I add elements. https://code.sololearn.com/cBYJYLKnYpHE/?ref=app

10th May 2021, 3:41 AM
Rishi
Rishi - avatar
4 Answers
+ 1
I can't see any dynamic array in your program. What is it that you need help with ? Also it's better to provide some description about the problem and the program in your question description to help others to understand your problem and in turn help you solve it.
10th May 2021, 3:48 AM
Arsenic
Arsenic - avatar
0
You can use malloc and realloc for dynamically allocating memory for an array. It might slow your program down a bit but would improve memory management.
10th May 2021, 10:45 AM
Thoq!
Thoq! - avatar
0
Thoq! Oh okay noted 📝📝📝
10th May 2021, 3:23 PM
Rishi
Rishi - avatar
0
Arsenic I didn't use any dynamic arrays in my program, rather I used a large array by guessing the upper limit of the number of elements. If you read my program and my description of my question, you'll know what I'm talking about. Thank you for your consideration
10th May 2021, 3:26 PM
Rishi
Rishi - avatar