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
just olya [345]
4 years ago
12

Can somebody explain me what this code does in a few or one sentence?#include #include using namespace std;int main () { const i

nt NUM_ELEMENTS = 8; vector numbers(NUM_ELEMENTS); int i = 0; int tmpValue = 0; cout << "Enter " << NUM_ELEMENTS << " integer values..." << endl; for (i = 0; i < NUM_ELEMENTS; ++i) { cout << "Enter Value#" << i+1 << ": "; cin >> numbers.at(i); } for (i = 0; i < (NUM_ELEMENTS /2); ++i) { tmpValue = numbers.at(i); numbers.at(i) = numbers.at(NUM_ELEMENTS - 1 - i); numbers.at(NUM_ELEMENTS - 1 - i) = tmpValue; } system ("pause"); return 0;}
Computers and Technology
1 answer:
goblinko [34]4 years ago
4 0

Answer:

The program declares and array of 8 elements and swap the position of the 1st element with the 8th; the 2nd with the 7th, the 3rd with the 6th and the 4th with the 5th element

Explanation:

First, I'll arrange the code line by line, then I'll start my explanation from the variable declaration at line 4

#include

using namespace std;

int main () {

const int NUM_ELEMENTS = 8;

vector numbers(NUM_ELEMENTS);

int i = 0;

int tmpValue = 0;

cout << "Enter " << NUM_ELEMENTS << " integer values..." << endl;

for (i = 0; i < NUM_ELEMENTS; ++i)

{

cout << "Enter Value#" << i+1 << ": "; cin >> numbers.at(i);

}

for (i = 0; i < (NUM_ELEMENTS /2); ++i)

{

tmpValue = numbers.at(i); numbers.at(i) = numbers.at(NUM_ELEMENTS - 1 - i);

numbers.at(NUM_ELEMENTS - 1 - i) = tmpValue;

}

system ("pause");

return 0;

}

Line 4: This line declares an instant constant variable NUM_ELEMENTS with a constant value of 8. Meaning that the value cannot be changed during program execution.

Line 5: This line declares a vector array that can change in size. Here, it was declared with size 8.

Line 6 & 7: These lines declares integers variables i and tmpValue with an initialised value of 0, each.

Line 8: This line prints the following string; Enter 8 integer values...

Line 9 to 12: These lines represent an iteration which starts from 0 to 7.

Side Note: When an array is being declared, the index starts from 0 and ends at 1 less that the array size.

So, during this iteration, it accepts inputs into the array from index 0 to 7 i.e. from the first element till the last

Line 13 to 17: This is also an iterative statement. But what this iteration does is that, it swaps elements of the array (as stated in the answer section)

The iteration starts from 0 and ends at a value less than NUM_ELEMENTS/2

Note that NUM_ELEMENTS = 2

So,we can conclude that the iteration starts from 0 till a value less that 8/2

Iteration: 0 till a value less that 4

So, that's 0 to 3 (the iteration is done on array element at index 0,1,2 and 3).

When iteration is at 0, the following is done

tmpValue = number at index 0 i.e. a temporary value is used to store the number at index 0 of the array

Number at 0 = number at (8-1-0)

i.e. number at 0 = number at (7)

Number at 7 is then equal to tmpValue

Swap Completed.

The same is done for index 1,2 and 3.

You might be interested in
the handles the overall activity of the computer and provides services such as memory management, input/output activities, and s
Alisiya [41]

The operating system controls the overall activity of the computer and furnishes services such as memory management, input/output activities, and storage management.

<h3>What is operating system?</h3>

An operating system (OS) is the programme that controls all other application programmes in a computer after being installed into the system first by a boot programme. Through a specified application programme interface, the application programmes seek services from the operating system (API).

It controls the memory, operations, software, and hardware of the computer. You can converse with the computer using this method even if you don't understand its language. A computer cannot function without an operating system.

An operating system performs three primary tasks: managing the computer's resources, including the CPU, memory, disc drives, and printers; creating a user interface; and running and supporting application software.

Hence, The operating system controls the overall activity of the computer and furnishes services such as memory management, input/output activities, and storage management.

To learn more about operating system refer to:

brainly.com/question/19999569

#SPJ4

4 0
2 years ago
Indicate whether the statement is true or false. ____ 1. Autoglobal array elements are referred to with an index number. ____ 2.
Masteriza [31]

Answer:

The answer to this question can be defined as follows:

For question 1,  it is "False".

For question 2, it is "True".

Explanation:

The index number refers to autoglobal array elements. To respond to either a global variable inside a method, users need the global keyword. It will omit the username for the dollar lead if you're using the variable as just an index to the $GLOBALS list, that's why question 1 is "False".

Its process attribute specifies how its form data could be sent (for the data files. This site is in the method category would have been sent). It process-data can be transmitted in URL variables (using method = "get") or HTTS (using method = "post") after transaction, that's why question 2 is "True".

7 0
3 years ago
Different project management steps are initiating, planning, executing, monitoring and controlling, and closing a project. Which
ser-zykov [4K]

Answer:

All steps of project management until the closure of the project are very critical and important for the success of the project.

Explanation:

The steps that are very critical and important for the success of the project.

Initiation:

This is a very beginning step of any project in the project management practices. In this step, mainly, project feasibility is carried out and drafted. at this step, management takes decisions that this project would be profitable or not for the organization. If proper measure and future prediction do not measure properly then this stage would affect the project success criteria. Because, if the base of any project is built on the wrong steps and measures, will lead to failure. At this stage, management takes the decision based on a feasibility document and business case document to ensure if it feasible or profitable to the organization.

Planning:

This is a very crucial step of project planning, and mistakes in this stage will lead the project toward failure. after receiving the green signal at the initiation stage, the proper project plan is carried out in a documented form. This project plan will guide the project manager and all stakeholders of the project in making the project successful. So, a well-written project plan is very critical and important for project success than any other phase of project management. Because the project plan gives the direction to the team to carried out the project execution process smoothly, it helps in handling risk and mitigation strategies to solve the risk, finance management, task management and in achieving timely deliverables.

Execution:

The planning phase and execution phase are most commonly associated with project management. This phase of project management is all about building deliverables and ensure timely delivery to customers for their satisfaction.  Team leader and/or project manager make this happen by allocating the required resources to develop the deliverables and keeping team members focus on their assigned tasks. This phase relies on the project  planning phase.

Monitoring and Controlling:

Monitoring and controlling are sometimes combined with the execution phase of the project because they often occur at the same time and carried out parallel to each other. At this stage, team performance, progress, and other project-related matrices are carried out to track their own progress. In this stage, key performance indicators are calculated, track variation from allocated resources such as cost and time, etc. This stage is important for project success, because if you don't deliver the quality and timely work then you may linger the project that directly affects the project cost and time.

Closure:

The team closes the project as they finished the project and customers/stakeholders approve the project output i.e product and then release the resources. This step is not crucial for project success as other all of the previous stages. but at this stage, effective communication, document finalization, and lesson learned document are required.

6 0
4 years ago
Zack wants to be a landscape designer.which qualification would be best prepare him for work in this career
katen-ka-za [31]
Landscape design or landscape horticulture. a bachelor degree for these.
4 0
3 years ago
Read 2 more answers
Which of the following best describes a computer virus? another name for a software bug the product of a computer crash software
nikdorinn [45]
A computer virus is software that can spread itself
8 0
4 years ago
Read 2 more answers
Other questions:
  • The US government takes the protection of patients' private information very seriously. In 1996, went into effect. This law prot
    14·1 answer
  • Computers store temporary Internet files in the Recycle Bin. These files take up space and slow down a computer. Which tool can
    10·1 answer
  • The set of instructions that tells a computer
    12·2 answers
  • What are the disadvantages of plasma display?
    9·1 answer
  • How many questions do you need to have on brainly before being able to send messages?
    14·1 answer
  • At Tech Edge Inc., a special team is set up for making a robot capable of assisting blind people in daily activities. The member
    5·1 answer
  • If E=mc2 then what does F equal?
    10·1 answer
  • Multiple Choice
    5·1 answer
  • What is a digital dashboard, and why are they becoming an increasingly popular tool?
    15·2 answers
  • Cho lược đồ CSDL “Quản lý BÁN HÀNG” có các bảng như bên dưới. (Thuộc tính in đậm và
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!