How can fix run time error in this
Hello @AjAy03,
Run time error is one of the common errors you would face with your code in future.
So, letβs understand the reasons that lead to run time error:
- Invalid memory access during run-time.
- Accessing linked list nodes that do not exist.
- Dividing by zero.
- Large allocation of memory together/Large Static Memory Allocation.
- Making a silly mistake.
In your code, you are facing the issue mentioned in point 1.
How, are you so sure that there would not be more than 100 elements in the array?
a[100]
Solution:
cin >> n;
int a[n];
Hope, this would help.
Give a like, if you are satisfied.
1 Like
Thanks for detailed explanation