Program that generates a new list

Assignment Help C/C++ Programming
Reference no: EM13907638

Given a list listA of numbers, write a program that generates a new list listB with the same number of elements as listA, such that each element in the new list is the average of its neighbors and itself in the original list. For example, if listA = [5, 1, 3, 8, 4], listB = [3.0, 3.0, 4.0, 5.0, 6.0], where the values in listB were computed as follows:

(5 + 1)/2 = 3.0
(5 + 1 + 3)/3 = 3.0
(1 + 3 + 8)/3 = 4.0
(3 + 8 + 4)/3 = 5.0
(8 + 4)/2 = 6.0

listA can be hardcoded at the begining of your program, but the solution should work for other lists as well (in particular if we modify the values of the list, the program should work with the new values).

Sample run:

listA = [5, 1, 3, 8, 4]

listB = [3.0, 3.0, 4.0, 5.0, 6.0]

Reference no: EM13907638

Questions Cloud

What are the sales objectives for new sales representative : What are the sales objectives for the new sales representative? What role will the compensation design play in motivating the new sales representative? What kind of sales incentive plan do you recommend? Why
What other dbms constructs came after relational databases? : What other DBMS constructs came after relational databases?
Kenya company standard cost accounting system recorded : Kenya Company's standard cost accounting system recorded this information from its June operations.
Compute the sum of the first : Assume there is a variable , h already associated with a positive integer value. Write the code necessary to compute the sum of the first h perfect squares, starting with 1 .
Program that generates a new list : Given a list listA of numbers, write a program that generates a new list listB with the same number of elements as listA, such that each element in the new list is the average of its neighbors and itself in the original list. For example, if listA..
Write an sql drop statements that will drop the all tables : Write an SQL DROP statements that will drop the all tables. Add these statements to the appropriate location within the script file - Write a SQL CREATE TABLE statement to create the ALLOCATION table. Add the SQL statement to the appropriate locati..
Analysis of flexible budgets and standard costs emphasizes : Analysis of flexible budgets and standard costs emphasizes the importance of a similar unit of measure for meaningful comparisons and evaluations.
Program that loads the keywords and definitions : 1) Develop the part of the program that loads the keywords and definitions from the external file
Folsom custom skis as discussed in the chapter opener : Folsom Custom Skis, as discussed in the chapter opener, uses a costing system with standard costs for direct materials,

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Refined into a generalization/ specialization hierarchy

Which classes might be refined into a generalization/ specialization hierarchy? List the superclass and any subclasses for each of them.

  Write a function to compute the magnitude f

write a function to compute the magnitude F and direction angle of a two-dimensional force F by using two components of the force fx,fy as its parameters,returning F and using the reference to pass theta value .

  Prints out a multiplication table up to a specification

Create a program using C++ that prints out a multiplcation table up to a specfic limit. The code should prompt the user for the limit and then print out the table.

  Write program which prompts user to enter numbers

Write down the program which prompts the user to enter numbers, findsout how many positive and negative values have been entered, and calculates sum and average of numbers entered.

  Write a c matrix multiplication program which you can

write a c matrix multiplication program which you can instrument to monitor and measure execution time as a function of

  What happens when c is a function of just one variable

What happens when C is a function of just one variable? Can you provide a geometric interpretation of what gradient descent is doing in the one-dimensional case?

  Two-dimensional array to compute the polar coordinates

Write a C program that will read from the input file the time, the x-coordinate, and the y-coordinate values into a two-dimensional array. The program will use the two-dimensional array to compute the polar coordinates.

  You will write a program that reads a text file

You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..

  Accept positive and negative numbers in its input sequence

the program must accept positive and negative numbers in its input sequence, and ?nd the largest and smallestof the numbers entered whether they are all positive, all negative, or a combination of both positive and negative.

  Write an array-returning method

Write an array-returning method that takes a two-dimensional array of chars as a parameter and returns a single-dimensional array of Strings as follows:

  How many generations do you want to wait

How many generations do you want to wait? How many jackalopes do you have?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd