solve bus-error (core dumped), run-time error

- Run time error on linux.
  - 'n' is declared but not initialized, neither its value is taken from user.
  - 'n' contains garbage value, thus throws run time error.
This commit is contained in:
Vaibhav Gupta 2018-10-02 17:05:25 +05:30 committed by GitHub
parent f499342869
commit 485d1b2bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,8 +6,10 @@ using namespace std;
int main()
{
int n;
cout<<"Enter the number of elements in your array: ";
cin>>n;
int Array[n];
cout<<"\nEnter any 6 Numbers for Unsorted Array : ";
cout<<"\nEnter any "<<n<<" Numbers for Unsorted Array : ";
//Input
for(int i=0; i<n; i++)