0% found this document useful (0 votes)
99 views4 pages

Array 1 PDF

The document contains 10 questions about arrays. The questions cover topics like: creating and printing an array of integers; checking if a number is present in an array; finding minimum and maximum elements; reversing, sorting, and finding the kth largest/smallest elements of an array; counting occurrences of a number; sorting an array containing 0s, 1s, and 2s; calculating the range of an array; and moving all negative elements to one side. For each question, hints or solutions are provided, along with sample input/output examples. The reader is instructed to write code that first takes the array size as input, then elements, and performs the specified operation.

Uploaded by

makogag649
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views4 pages

Array 1 PDF

The document contains 10 questions about arrays. The questions cover topics like: creating and printing an array of integers; checking if a number is present in an array; finding minimum and maximum elements; reversing, sorting, and finding the kth largest/smallest elements of an array; counting occurrences of a number; sorting an array containing 0s, 1s, and 2s; calculating the range of an array; and moving all negative elements to one side. For each question, hints or solutions are provided, along with sample input/output examples. The reader is instructed to write code that first takes the array size as input, then elements, and performs the specified operation.

Uploaded by

makogag649
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Array

Basic Questions:

1) Create an Array of size 10 of integers. Take input from the user for these
10 elements and print the entire array after that.

2) Check whether n is present in an array of size m or not.

Input - n,m (Input number, size of array)

- Take input n elements for the array

Output -> true/false


[ Hint : - Create a dynamic array]


3) Find the minimum and maximum element in an array.

[ Solution: https://www.geeksforgeeks.org/program-find-minimum-maximum-element-array/]

Here in sample input : 5 is the size of array

4) Write a program to reverse the array.

[Hint: use indexes]


Here , 5 is the size of array and then elements of arrays are input


5) Write a program to sort the given array.

[Hint: use any sorting algorithm i.e. https://www.geeksforgeeks.org/sorting-algorithms/]

Here, 6 is the size of array and then the elements are input by the user


6) Find the Kth largest and Kth smallest number in an array.

Here , K = 3 , 9 is the size of array :


7) Given an number n. Find the number of occurrences of n in the array.

Here n = 3 in the sample input , 11 is size of array and occurrence of 3 is 6 times in the given array


8) Given an array which consists of only 0, 1 and 2. Sort the array without
using any sorting algorithm.
Here, 9 is the size of array input by the user followed by the elements input


9) Find the range of the array. Range means the difference between the
maximum and minimum element in the array.
here , 6 is the size of array followed by the input of elements


Here , Range = 91-(-3) = 94

10) Move all the negative elements to one side of the array.




NOTE:
You have to write the code for each question
Such that,
First you have to write the code to input the size of array
Second input the elements also by the user
And then perform the mentioned algorithm

You might also like