Make C code please Write a program that asks the user for an integer value great
ID: 3764054 • Letter: M
Question
Make C code please
Write a program that asks the user for an integer value greater than zero. It will verify that the user has entered a valid value and then try to allocate enough space using malloc for an array of integers with N elements where N is the integer they entered in the first step. Your program should make sure that the allocation worked and then use a for loop and the square brackets operator to give every integer variable location in the dynamically allocated array the value of its index. For example the variable that is zero elements away from the base address should get the value 0, the value that is 1 element away from the base address should get the value 1 and so on. When you have initialized all the values use another for loop and the square bracket operator to print them in reverse order separated by new lines. Print a line that has 3 asterisks in it by itself and then use another for loop that prints all of the array elements in order but without using the square bracket operator. To do this you will need to use only the dereference operator and pointer arithmetic (i.e., increment or decrement the pointer). Your program output should look something like the following:Explanation / Answer
printf("***" );
for(n=0;n<=9;n++)
{
printf( "Elements at index %d : n");
printf("Press any key to continue...");
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.