152k views
5 votes
Write a Program in C language using arrays:

Part 1:
-Write a program that stores eight doubles in an array. You can allow the user to enter
the numbers from the keyboard or you can initialize the array with eight doubles.
-Your program should then display:
- each number on one line (to one decimal place of accuracy)
-for example: 2 19.4 -11.2 7.3 . . .
- each number on one line in reverse order (again, to one decimal place)
- the sum of the numbers
- the average of the numbers
- each number that is higher than the calculated average value

Part 2:
- Write a program that declares a one-dimensional array of integers with 24 elements.
Fill the array with random integers (use a loop). Neatly output each element in the
one-dimensional array.

- Next convert your one-dimensional array of 24 elements into a two-dimensional
array of 6 x 4 elements. Neatly output each element of the two-dimensional array.
The values will be identical to the one-dimensional array – you’re just converting
from one dimension to two.

User MarkA
by
3.6k points

1 Answer

5 votes

Hello!!! I'm not sure I can answer that but I can give you advice. An array is a homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate, relative to the first element. C and C++ arrays that include static modifier are static. C and C++ arrays without static modifier are fixed stack-dynamic . C and C++ provide fixed heap-dynamic arrays. C# includes a second array class Array List that provides fixed heap-dynamic . Perl, JavaScript, Python, and Ruby support heap-dynamic arrays. Access function maps subscript expressions to an address in the array. Access function for single-dimensioned arrays: address(list[k]) = address (list[lower_bound]) + ((k-lower_bound) * element_size). Hope this helps!!

User Ben Olsen
by
4.4k points