Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

First, write a function deleteFromArray which receives three arguments in its parameters: an array of integers; an offset indicating a position in the array; and an integer containing the size of the array.

The function then deletes the value at the position indicated by the offset (by shifting all values to the right of the deleted value one offset to the left), and finally returns the new size of the array.

Next, write a program to use this function. Particularly, the program first sets, declares, and initializes an array as follows: int myValues[10] = {0,1,1,2,3,5,8,13,21,34}; int arraySize = 10; Next, the program repeatedly displays the array to the user, asking whether they wish for a something to be deleted. If the user responds in affirmative, the program asks them for the offset in the array of the value to be deleted.

It then calls your deleteFromArray function to carry out the actual deletion, receiving the new size of the array from the function. If the user asks to delete from an offset that goes beyond the end of the array, an appropriate message is displayed stating that the deletion cannot be carried out.

The program ends the first time that the user chooses not to delete a value from the array. Your main function may also call other functions to carry out some of its work. Here is an example execution of the required program (input typed by the user is in green).

The formatting of your program's output should match this example. Array: {0,1,1,2,3,5,8,13,21,34} Want to delete something? (y/n) y Offset to delete? 3 Array: {0,1,1,3,5,8,13,21,34} Want to delete something? (y/n) y Offset to delete? 7 Array: {0,1,1,3,5,8,13,34} Want to delete something? (y/n) y Offset to delete? 9 Sorry, can't delete that.

Want to delete something? (y/n) n Goodbye!

Carefully note the following in the example output above: The user first asks for deletion at offset 3, which refers to the value 2 in the array. Every value to the right of the 2 in the original array must be consequently copied one position to the left.

For example, value 8 was at offset 6 before the first deletion (we deleted value 2, remember?), but appears at offset 5 (one left of its previous location) after the deletion. Also note that 10 elements were displayed before the first deletion, but 9 elements are displayed after it.

To get this right, you need to keep track of the number of elements in the array, as well as the array itself. Also note that when the user tries to delete the item at offset 9 after the two deletions, when there were only 8 valid elements remaining in the array, the program declines to carry out the deletion.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91900745
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Programming Language

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As