Coding Questions Sheet 1 2024 PDF
Document Details
Uploaded by LuminousRadon
GLA University Mathura
Tags
Summary
This PDF contains coding questions focused on array manipulation, including reversing, sorting, and removing specific elements (e.g., prime numbers). The questions are designed for secondary school students and involve basic programming concepts.
Full Transcript
## Coding Questions Sheet 1 ### Example: **Input:** Array elements are: 10, 20, 30, 40, 50 **Output:** Array elements after swapping (reversing): 50, 40, 30, 20, 10 ### Input Format 1. Take an integer n from the user as the size of the array. 2. Take n elements from the user. ### Constraints...
## Coding Questions Sheet 1 ### Example: **Input:** Array elements are: 10, 20, 30, 40, 50 **Output:** Array elements after swapping (reversing): 50, 40, 30, 20, 10 ### Input Format 1. Take an integer n from the user as the size of the array. 2. Take n elements from the user. ### Constraints 1. n>=1 && n<=10000 ### Output Format 1. It should print the elements of array after swapping. ### Sample Input 0 4 1 2 3 4 ### Sample Output 0 4 3 2 1 ### 26. Remove Prime Program to delete prime numbers from an array. ### Example: **Input:** Array elements are: 100, 200, 31, 13, 97, 10, 20, 11 **Output:** 100 200 10 20 ### Input Format 1. Take an integer n for the size of the array. 2. Take n elements for the array from the user. ### Constraints 1. n>0 && n<=10000 2. array[n]>0 && array[n]<=10000 ### Output Format 1. It should print the array after removing the prime numbers. ### Sample Input 0 5 7 11 15 16 19 ### Sample Output 0 15 16 ### 27. Array Sorting 4 Program to sort array elements in ascending order. ### Example: Input array elements are: 50, 10, 20, 40, 30 **Output:** * The code likely outputs the sorted array: 10, 20, 30, 40, 50 ### 25. Swap Array 1 Program to swap first element with last, second to second last and so on (reversing elements). ### Example: **Input:** Array elements are: 100, 200, 31, 13, 97, 10, 20, 11 **Output:** Array elements after removing prime numbers: 11, 20, 97, 13, 31, 200, 100 ### Input Format 1. Take an integer n as the size of the array. 2. Take n elements of the array from the user. ### Constraints 1. n>0 && n<=10000 ### Output Format 1. First line should print the smallest element of the array. 2. Second line should print the largest element of the array. ### Sample Input 0 5 2 65 98 75 21 ### Sample Output 0 2 98 ### 30. New Paradise Raman and Asha wanted to buy a new house from their savings. For deciding the location, both of them looked for a place which had the maximum routes to travel to their office. Given below is the number of places the housing agency gave them, and the number of routes from each place. Find out the no. of best possible locations for their new paradise. ### Input Format A single integer number of locations. Routes through each location, a list of integers ### Constraints N/A ### Output Format A single integer to show the no. of house with maximum routes ### Sample Input 0 10 2 1 5 5 5 2 1 4 5 5