Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Create a new project named Login_labo2_t02. In the Source Folder (src) of this project create a new C source file called cubes 02.c. Copy

image text in transcribed

2. Create a new project named Login_labo2_t02. In the Source Folder (src) of this project create a new C source file called "cubes 02.c". Copy the contents of the cubes 02 file, into the "cubes 02.c source file. Write your code where indicated to reproduce the function of the cubes 01.c program of Task-1, above. Other than the output title, the output of these two programs is identical. These two programs differ only in the way the two arrays, namely "values" and "cubes", are scanned. That is, how values are stored and retrieved from these arrays. In the cubes_01.c program, the arrays are scanned using the ARRAY INDEX method, whereas in the cubes_02.c program of Task-2, the arrays are scanned using the POINTER ARITHMETIC method. An brief example of these two array processing methods is given below. ARRAY INDEXING: int values [10]; // Declare an integer array of 10 values values [5] = 31; // The value of 31 is placed into the 6th array element. printf("Value of the sixth element = [d] ", values (51); POINTER ARITHMETIC: ================== int values [19]; // Declare an integer array of 10 values int #pV; // Declare an integer pointer. PV = values; // Pointer pv is set to point to the first element of the array "values". // Another way to do this is: pV = &values [0]; *{pV+5) = 31; // The value of 31 is placed into the 6th array element of the "values" array. printf("Value of the sixth element = [d] ", *(pV+5)); Copy the contents of the cubes_02 file, into the "cubes_02.c" source file and enter your code where indicated. Please DO NOT use the array names "values" and "cubes" after the indicated point in the given program. Instead, reference these arrays using the "pl" and "pS"pointers. Marks will be awarded only if you use POINTER ARITHMETIC. The output from this program should look like the following. Array traversal by "ARRAY INDEX ING" Value Cube EEEE 1 . Z 3 4 5 6 1 1 8 27 64 125 216 343 512 729 1000 1331 1728 7 R 9 10 11 12 ::: Program Terminated

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions