Write a program that asks the user for an integer value gre ater than zero. It will verify that the user has entered a valid value and then try to alloc ate enough space elements where n is the...


In C programming


Write a program that asks the user for an integer value gre ater than zero. It will verify that the<br>user has entered a valid value and then try to alloc ate enough space<br>elements where n is the integer<br>using malloc for an array of n<br>they entered in the first step.<br>Your program should make sure that the allocation worked and then call a function named<br>fillArray that uses a for loop and the square brackets operator to fill the array with the first<br>n odd numbers. For example, the variable that is zero elements away from the base address should<br>get the value 1, the value that is 1 element aw ay from the base address should get the value 3, and<br>so on (see the screen shot below). A fterwards, call another function called printDown that uses<br>anot her f or loop and the square brackets operator to print them in reverse order separated by<br>new lines.<br>Print a line that has 3 as terisks (**) in it by itself. Finally, call anot her function called<br>that uses another for loop that prints all of the arr ay elements in order but without using the<br>square bracket operator. To do this, you will need to use only the derefere nce operator and<br>point er ar it hmet ic (i.e., increment or decrement the pointer).<br>Don't forget to free the memory before the program ends.<br>printUp<br>

Extracted text: Write a program that asks the user for an integer value gre ater than zero. It will verify that the user has entered a valid value and then try to alloc ate enough space elements where n is the integer using malloc for an array of n they entered in the first step. Your program should make sure that the allocation worked and then call a function named fillArray that uses a for loop and the square brackets operator to fill the array with the first n odd numbers. For example, the variable that is zero elements away from the base address should get the value 1, the value that is 1 element aw ay from the base address should get the value 3, and so on (see the screen shot below). A fterwards, call another function called printDown that uses anot her f or loop and the square brackets operator to print them in reverse order separated by new lines. Print a line that has 3 as terisks (**) in it by itself. Finally, call anot her function called that uses another for loop that prints all of the arr ay elements in order but without using the square bracket operator. To do this, you will need to use only the derefere nce operator and point er ar it hmet ic (i.e., increment or decrement the pointer). Don't forget to free the memory before the program ends. printUp

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here