Question
Download Solution PDFGiven the array arr[ ]= { 10, 20, 30, 40, 50 }, which of the following statement is true?
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFThe correct answer is Option 1) It is neither possible to add 60 or delete 50 from the array.
Key Points
- In programming languages like C, C++, and Java, arrays are fixed-size data structures.
- Once an array is created with a defined size (e.g.,
arr[5]
), you cannot add or remove elements directly. - You can only modify existing elements within the allocated size.
- Hence, trying to add 60 to the end or beginning, or delete 50 from the array is not directly possible without creating a new array and copying elements manually.
Additional Information
- Option 2 – Add 60 at end: ❌ Not possible directly in fixed-size arrays without exceeding bounds.
- Option 3 – Add 60 at beginning: ❌ Same issue, array size is fixed and elements cannot be shifted automatically.
- Option 4 – Delete 50: ❌ Deleting an element shifts memory, which isn't supported in fixed-size arrays. Manual copying required.
Conclusion: In fixed-size arrays, elements cannot be dynamically added or deleted. Hence, Option 1 is correct.
Last updated on Nov 25, 2024
-> BELTRON Programmer 2024 Notification has been released on the official website.
-> The Bihar State Electronics Development Corporation Limited (BELTRON) has announced a recruitment drive for Programmer positions on a contractual basis.
-> Specific vacancy details will be shared separately.
-> Interested candidates can apply online from November 11, 2024, to December 10, 2024.
-> The Minimum age of the candidates should be 21 years and maximum age should be 59 year of age.