Write a
abcd.
then the output should be
dcba
Use a period as a sentinel value to mark the end of the input. Call the array letterBox. For this exercise you need not use any functions. This is just a toy program and can be very minimal.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Problem Solving with C++, Student Value Edition Plus MyLab Programming with Pearson eText - Access Card Package (10th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Modern Database Management (12th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (7th Edition)
Java How To Program (Early Objects)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Write a program that first reads an integer for the array size, then reads numbers intothe array, and finally outputs how many numbers have values that are greater than theaverage. For practice reasons, try not to use the index notation of arrays (e.g. myarray[i])at all. Use pointers instead.arrow_forwardWrite a small piece of pseudo-code for generating a histogram H[L] for an intensity image I[YDIM][XDIM], where L is the total level of intensities of the image, H is the histogram array, XDIM * YDIM are the size of the image, and I[i][j] is the intensity value of the pixel at location (i,j), with i = 1, …, YDIM, and j = 1,…, XDIM. You might choose to use a certain program language that you are familiar with to write the code. You don’t have to compile the code.arrow_forwardWrite a program that reads 10 numbers, finds the largest number, prints it, finds the smallest number, and prints it.Without using arrays.without using max,min.without using Limits.harrow_forward
- Implement the vacuum cleaning agent function in Python/Java for the scenario described below: Consider two-dimensional Boolean array of size m x n (m and n can each be equal to 4) where m is the number of rows, and n is the number of columns. Obtain numerical positive integer values for m and n as inputs from the user. Generate random numbers and scale them down to either a “0” or a “1” according to whether they represent “Clean” or “Dirty”, respectively. After filling the array with 0s or 1s, start at some random array position indicating the initial position of the vacuum cleaner. First check if at that current position, there is the presence of a “Dirt” or not determined by whether 0 or 1 is filled in at that initial position of the vacuum cleaner. If there is a “Dirt”, clean it, and if there is no “Dirt” do a No-operation. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If…arrow_forwardI have a java program that is supposed to compare the sums of the columns of a 2D array and output the index of the column with the largest sum. I was able to find the column sums but I do not know how to compare the different sums and output the index of the largest sum. Here is the piece of code that finds the column sums: int [] colSum = new int [arr[0].length]; for (int k = 0; k < colSum.length; k++) { System.out.print(colSum[k]); ----> colSum[k] = the column sums How do I compare the integers in colSum[k] to find the largest sum and how do I output the index of the largest sum?arrow_forwardWrite a Java program that reads a list of double-precision grades (1-100) from the keyboard into an array named grade. The grades are to be counted as they’re read, and entry is to be terminated when a negative value has been entered. After all the grades have been input, your program should find and display the sum and average of the grades. Implement sum and average as two functions.arrow_forward
- Suppose we expect the elements of the array a to be ordered so thata[0] ≤ a [1] ≤ a [2]≤ ...However, to be safe we want our program to test the array and issue a warningin case it turns out that some elements are out of order. The following code issupposed to output such a warning, but it contains a bug. What is the bug?double[] a = new double[10];<Some code to fill the array a goes here.>for (int index = 0; index < a.length; index++)if (a[index] > a[index + 1])System.out.println("Array elements " + index +" and " + (index + 1) + " are out of order.");arrow_forwardGiven an array below, write a program in Java language to print all numbers which are greater than the average of all numbers in the array. int []array = {1,10,-8,16,-12,34,0,19,-23,14}arrow_forwardWrite a program to input a list of numbers in an array and then rearrange this array in such a waythat all the odd numbers appear in the beginning of the array and all the even numbers appear in theend of the array. E.g., if the input list is 1,4,2,7,6,5,9, then after rearrangement the list should be:1,7,5,9,4,2,6.arrow_forward
- Write a program to shift all the zero present in the array in the alternative order, For example.Input array: -1 2 0 8 5 0 0 6Output array: -1 0 2 8 0 5 0 6Sample Input:First input should describe the number of elements in the array and in the second line take all the input. 50 1 2 0 3Output: -1 0 2 0 3arrow_forwardtrying to write a function that takes an array of integers as input and returns the sum of all the even numbers in the array. But, my current implementation doesn't seem to be working correctly. Whenever I run the function, I'm getting incorrect results. Can you take a look at my code and suggest a solution? public int sumEvenNumbers(int[] arr) { int sum = 0; for (int i = 0; i <= arr.length; i++) { if (arr[i] % 2 == 0) { sum += arr[i]; } } return sum;}arrow_forwardYou are given an int variable k, an int array zipcodeList that has been declared and initialized, an int variable nZips that contains the number of elements in zipcodeList, and a bool variable duplicates. Write some code that assigns true to duplicates if there are two adjacent elements in the array that have the same value, and that assigns false to duplicates otherwise. Use only k, zipcodeList, nZips, and duplicates. duplicates = false; for (k=0; !duplicates && k<nZips-1; k++)if (zipcodeList[k] == zipcodeList[k+1]) duplicates = true;arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education