Question

programming in C a study guide question. how can I access an element of a dynamically...

programming in C a study guide question.

how can I access an element of a dynamically allocated array without using [] operator

Given ar2 is defined as int** ar2, access ar2[i][j] without using the [] operator.

please provide code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Editable code

for (int i = 0; i < 4; i++) {

                        for (int j = 0; j < 4; j++) {

                                    if(i==2 && j==1)

                                    printf("%d", *(*(p + i)+j));

                        }

                       

            }

Add a comment
Know the answer?
Add Answer to:
programming in C a study guide question. how can I access an element of a dynamically...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello can someone help me figure this out for my revision using C Programming. thanks! Given...

    Hello can someone help me figure this out for my revision using C Programming. thanks! Given the following function prototype: void trimPositive(int* *arr, int *size) ; write the corresponding function definition such that: given any (dynamically allocated) array of ints and its size via the arr and size parameters, the result of your function is that: a) the int* array argument points to a new (dynamically allocated) array that is completely full, and whose values are exactly the positive values...

  • Principles of Programming midterm study guide help! 1.) ______ Which of the following would reference the...

    Principles of Programming midterm study guide help! 1.) ______ Which of the following would reference the 9th element of an array named junk?   junk[0]         B.    junk[8]      C.    junk[9]      D.    junk[7] 2.)    ______ To completely sort a list of 10 values using a bubble sort, the greatest possible number of required pair comparisons is ________ . 8       B.   9      C.   10        D.   11 3.)     A two-dimensional array declared as int stuff[6][5] has how many elements?

  • Using C programming

    Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...

  • I have some questions about pointers/pointer arithmetic in C++ 1) Pointers and Pointer Arithmetic a.)       What...

    I have some questions about pointers/pointer arithmetic in C++ 1) Pointers and Pointer Arithmetic a.)       What is the difference between statically allocated arrays and dynamically allocated arrays (be brief) b.)      Which of the following pointers can be used for a dynamically allocated array? (Circle) char ptr; char * ptr; char ptr *; char ptr[]; char [] ptr; c.)       Show now, using that pointer, how to dynamically allocate array of characters of size 10: (don't use malloc) d.)      Which of the...

  • Please help with this coding 1.You need to dynamically allocate memory to read into a number...

    Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...

  • Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory...

    Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...

  • Java programming question: Here is the feedback I received "sort fails. Use Arrays class method to...

    Java programming question: Here is the feedback I received "sort fails. Use Arrays class method to sort." The actual question: Write a program as follows: Declare a five element array of Strings. Use a for loop and keyboard input to populate the array with the names of five friends. Sort the array in alphabetical order. Use a foreach loop to print the sorted array of friends, all on one line. Sample Output (inputs in italics) Enter the names of five...

  • C programming only please 5.2.3: Printing array elements with a for loop. Write a for loop...

    C programming only please 5.2.3: Printing array elements with a for loop. Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. (Notes) Note: These activities may test code with...

  • Programming Question 4: Operator Overloading [20 marks] The class SpecialArray represents an arra...

    C++ please Programming Question 4: Operator Overloading [20 marks] The class SpecialArray represents an array of integers. The class contains two data members: array (of type int"), which represents the array of integers, and size (of type int) that represents the size of the array. The class SpecialArray also overloads the following operators: operator: Compares two arrays. An array "A" is smallerhan an array "B" if the size of array "A" is smaller than the size of "B", or if...

  • (C++ programming) Need help with homework. Write a program that can be used to gather statistical...

    (C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT