I am stuck with one problem , please anyone help me to do this . The question is

Write a function to modify a list ( one dimensional array ) of numbers such that every number is replaced by the average of its immediate neighbours ( the value just above and just below ). Include appropriate special steps for the first and last elements .

friends , this is not a home work . I found this question in one question paper , i searched in many books for this problem , didn't get any hints . Can u please give me a rough idea about the question . Actually i don't want any ready made programs , ..please.....

I am stuck with one problem , please anyone help me to do this . The question is

Write a function to modify a list ( one dimensional array ) of numbers such that every number is replaced by the average of its immediate neighbours ( the value just above and just below ). Include appropriate special steps for the first and last elements .

First create a function prototype. You know you need an array,
you also know you need the array size. So create a prototype first.

From high school you know that the average of 2 numbers,a,b is
just (a+b)/2.0f; Use this information to find the average of
the array for each elements. For example the average of Array[3] ( assuming validity ), will be
(Array[3-1] + Array[3] + Array[3+1] ) / 3.0f;

You can do this for all elements in the array, except the first and the last, because there is nothing preceding the
first and there is nothing further than the last. In those case, you have to do something else.

Edited 6 Years Ago by firstPerson: n/a

This article has been dead for over six months. Start a new discussion instead.