1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
4 years ago
13

Write a C program that does a large number of references to elements of two-dimensioned arrays, using only subscripting. Write a

second program that does the same operations but uses pointers and pointer arithmetic for the storage-mapping function to do the array references. Compare the time efficiency of the two programs. Which of the two programs is likely to be more reliable

Computers and Technology
1 answer:
telo118 [61]4 years ago
6 0

Answer:

#include <stdio.h>

#include <time.h>

int main()

{

 

clock_t start, end;

double cpu_time_used;

 

//starting the cpu clock.

start = clock();

 

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

my_func_with_only_subscript();    

}

 

// closing the cpu clock.

end = clock();

 

// calculating time elapsed in secs.

cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;

 

printf("Time taken with subscript references::%f\n",cpu_time_used);

 

// starting the cpu clock

start = clock();

 

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

my_func_with_pointers();

}

 

// closing the cpu clock.

end = clock();

 

// calculating the time elapsed in array reference through pointers.

cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;

 

printf("Time taken with pointers::%f\n",cpu_time_used);

 

return 0;

}

// function to reference the 2D array through subscripts.

void my_func_with_only_subscript()

{ //assuming that the usage of

int arr[15][5] = {0}; //square matrice is not mandatory

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

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

arr[i][j]; //no operation is done, only accessing the element

}

}

return;

}

// function to reference the 2D array through pointers.

void my_func_with_pointers()

{ //assuming that the usage of

int arr[15][5] = {0}; //square matrice is not mandatory

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

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

*(*(arr+i)+j); //no operation is done, only accessing the element

}

}

return;

}

/******************************************************************************************************************************/

OUTPUT

[Attached in the attachments]

You might be interested in
The this reference . a) can be used implicitly b) must be used implicitly c) must not be used implicitly d) must not be used 25)
Gnom [1K]

Answer:

yeet

Explanation:

because computers

6 0
3 years ago
I need someone who knows HTML to finish the code.
Maksim231197 [3]
I recommend you go to Stacks Overflow . There are many experienced coders there that would gladly answer your question.
7 0
4 years ago
Read 2 more answers
Match each of the following steps of SDLC development to its position in the development process.
Arisa [49]

Answer:

Step One - problem/opportunity identification  (V)

Step Two - Analysis (III)

Step Three - Design (II)

Step Four - Development (I)

Step Five - Testing and Installation (IV)

Explanation:

In the field of software development, or systems engineering, SDLC which refers to software development cycle refers to a systematic way of building software applications, it shows unique stages with the outcome of each stage dependent on the previous, step has a unique task which range from the planning, analysis, development, testing and installation of the information system.

5 0
4 years ago
Scenario: You are part of an IT group managing Active Directory for a mid-size organization. A contracted research group with th
SCORPION-xisa [38]

Explanation:

1.

the answer to the first question is <u>organizational unit</u>. this is because in this scenario that we have before us, cost is a deciding factor. a unit as this can adapt to changes, it is flexible and also not very complex

2.

answer to question 2 is <u>PDC emulator</u><u>.</u><u> </u>this emulator can perform the function synchronization of time across every domain controller that is in the domain. other of its functions are, authentication and changing of passwords.

3.

the answer to the 3rd question is <u>child domain</u><u>.</u><u> </u>It is a factor in this scenario because it works well in a situation where there is an issue of slow network connection.

6 0
3 years ago
Given the Query Data Type, which of the following is incorrectly matched with the corresponding Storage Data Type?
Tamiku [17]

Answer:

<h2>c) Date : Date</h2>

Explanation:

A type of attribute of data is called data type in computer science, data types tells the interpreter how a person wants to use the data. The basic data types are supported by most of the programming languages, the basic data types are Integers, float, characters, strings, point numbers and arrays. The terminology may differ from one language to other.

3 0
3 years ago
Other questions:
  • 18. Which type of briefing is delivered to individual resources or crews who are assigned to operational tasks and/or work at or
    14·1 answer
  • a one-two paragraph summary on the Running Queries and Reports tutorials. Apply critical thinking and an academic writing style
    6·1 answer
  • The Analysis phase of the SDLC examines the event or plan that initiates the process and specifies the objectives, constraints,
    10·1 answer
  • The assignment of numeric codes to characters follows a specific order called a(n) _____.
    15·1 answer
  • my pc wants to run the highest graphics even though I restart it everyday and it gets around 10 fps and I have a 1080 Nvidia gra
    7·1 answer
  • You want to substitute one word with another throughout your document. What tool(s) should you use?
    9·1 answer
  • Sam plans to use this image in artwork for a brochure about airplanes. Which principles of page layout is Sam planning to use in
    11·1 answer
  • HELP PLEASE!!!
    7·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • A photojournalist is more employable than a reporter or a photographer because they can perform more than one job
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!