array function
• Create a function called show2D.
• This function should accept a two-dimensional array as parameter
and display its contents that are odd numbers on the screen.
• This function should work with any of the following arrays of
different sizes:
int hours[3][9];
int stamps[7][9];
int cities[15][9];
• Write a demo program to show how to use the function
show2D.
this is c++ program
I WROTE THE CODE ALONG WITH THE COMMENTS
I AM USING ONE 2D ARRAY { hours[3][9] }
CODE:
#include <iostream>
using namespace std;
//global variables initialization.
int const N=3;
int const M=9;
void show2D(int hours[N][M])
{
//variables declaration.
int i,j;
cout<<"\nOdd numbers of the 2D array: ";
for(i =0;i<N;i++) //for loop used to go row wise.
{
for(j=0;j<M;j++) //for loop used to go columns wise.
{
if(hours[i][j]%2!=0) //condition for odd number.
cout<<hours[i][j]<<" ";
}
}
}
int main()
{
//variables declaration.
int hours[N][M],i,j;
cout<<"Enter 2D Array: "<<endl;
for(i=0;i<N;i++) //input scanning.
{
for(j=0;j<M;j++)
{
cin>>hours[i][j];
}
}
show2D(hours); //calling the show2D() function.
return 0;
}
OUTPUT:
SCREENSHOT OF THE CODE:
array function • Create a function called show2D. • This function should accept a two-dimensional array...
Write a function in C# called show2D. The function should accept a two-dimensional array as an argument and display its contents on the screen. The function should work with any of following arrays: int hours[3][8]; int stamps[5][8]; int cities[14][8];
c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...
Create a new class called DemoSortingPerformacne Create a private method called getRandomNumberArray. It returns an array of Integer and has 2 parameters: arraySize of type int and numberOfDigits of type int. This method should create an array of the specified size that is filled with random numbers. Each random numbers should have the same number of digits as specified in the second parameter In your main method (or additional private methods) do the following: Execute selection sort on quick sort...
Create a php program that contains a multi-dimensional array called package. package contains the following arrays: colors; which has the values of at least 4 colors sizes; which has the values of at least 4 sizes locations; which has the values of at least 4 locations transport; which has the values of at least 4 types of transport The program should display a random sentence containing one value of, size, color, locations and transport. this is for web 2- php...
(C++ program )Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to the element 1 of the new array. Element 1 of the argument array should be copied to element 2 of the new array, and so forth....
Create a class called Reverse that reverses an array of integers. The class should have two method: - public static void reverse(int [] array) – Which calls the private recursive method, passing the array parameter and which two array elements should be swapped. - private static void reverseRecursive(int [] array, int startIndex, int endIndex) – Which swaps the two elements of the array parameter pointed to by the startIndex and endIndex parameters. The method should be called again, this time,...
Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance
Code written in NASM Function called findLargest Write a function called findLargest that receives two parameters: an unsigned doubleword array and the length of the array. The function must return the value of the largest array member in eax. Preserve all registers (except eax) that are modified by the function. Write a test program in main that calls findLargest three times, each call using a different array with different lengths. Function called countHits Write a function called named countHits that...
Write a C function f such that … function f accepts, as input, … a two-dimensional array of integers in which each row has three columns the number of rows in the array function f returns the sum of the odd integers in the given array of integers and returns zero if there are no odd integers in the array COMPILER STACK TRACE None PROGRAM EXECUTION STACK TRACE None COMPILER COMMAND LINE ARGUMENTS -lm INPUT OF THE TEST CASE 1 #define NUM_ROWS 5...
Create a new public static method called ‘isLatinSquare’ that passes in a two-dimensional array. This new method will return ‘true’ if the passed array is a Latin Square. isLatinSquare(int[][]) should be one or two lines of code