0% found this document useful (0 votes)
269 views

Array Assignment 1D

The document provides 10 programming problems involving 1D arrays in C++. The problems include writing functions to find the sum and average of an array, swap first and last elements, reverse elements, find largest and smallest elements, implement a menu-driven program with sort options, search for a value, binary search, merge two sorted arrays, merge two descending arrays, and copy elements to a third array following a specific sequence from two input arrays. Functions are to be written to solve each problem, taking the array and number of elements as parameters in most cases.

Uploaded by

Vikas Saxena
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
269 views

Array Assignment 1D

The document provides 10 programming problems involving 1D arrays in C++. The problems include writing functions to find the sum and average of an array, swap first and last elements, reverse elements, find largest and smallest elements, implement a menu-driven program with sort options, search for a value, binary search, merge two sorted arrays, merge two descending arrays, and copy elements to a third array following a specific sequence from two input arrays. Functions are to be written to solve each problem, taking the array and number of elements as parameters in most cases.

Uploaded by

Vikas Saxena
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Array Assignment (1D) 1 2 3 4 5 Write a C++ program to find the sum and average of one dimensional integer array.

Write a C++ program to swap first and last element of an integer 1-d array. Write a C++ program to reverse the element of an integer 1-D array. Write a C++ program to find the largest and smallest element of an array. Write a menu driven C++ program with following option a. Accept elements of an array b. Display elements of an array c. Sort the array using insertion sort method d. Sort the array using selection sort method e. Sort the array using bubble sort method Write C++ functions for all options. he functions should have two parameters name of the array and number of elements in the array. ! is one-dimensional array of integers. Write a C++ function to efficiently search for a data "A# from !. $f "A# is present in the array then the function should return value 1 and % otherwise. Suppose a one-dimensional array A& containing integers is arranged in ascending order. Write a user-defined function in C++ to search for an integer from A& with the help of 'inary search method( returning an integer % to show absence of the number and integer 1 to show presence of the number in the array. )unction should have three parameters * +i, array A& +ii, the number to be searched and +iii, the number of elements - in the array. Suppose A( '( C are arrays of integers of si.e /( -( and / + - respectively. he numbers in array A appear in ascending order while the numbers in array ' appear in descending order. Write a user defined function in C++ to produce third array C by merging arrays A and ' in ascending order. 0se A( ' and C as arguments in the function. Suppose 1. 2( 3 are arrays of integers of si.e /( -( and / + - respectively. he numbers in array 1 and 2 appear in descending order. Write a user-defined function in C++ to produce third array 3 by merging arrays 1 and 2 in descending order. 4iven two arrays of integers A and ' of si.es / and - respectively. Write a function named /$1 +, with four arguments( which will produce a third array named C. such that the following se5uence is followed. All even numbers of A from left to right are copied into C from left to right. All odd numbers of A from left to right are copied into C from right to left. All even numbers of ' from left to right are copied into C from left to right. All old numbers of ' from left to right are copied into C from right to left. A( ' and C are passed as arguments to /$1 +,. e.g.( A is 67( 8( 1( 9( :( 7; and ' is 6<( 7( =( :( 8( >( 1%; the resultant array C is 68( :( :( 8( >( 1%( =( 7( <( 7( 9( 1( 7;

10

You might also like