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
goldenfox [79]
2 years ago
13

What is the problem, if any, with the following code?The desired output is [3,19].

Computers and Technology
1 answer:
vfiekz [6]2 years ago
8 0

Answer: You need a temporary variable to hold the value 3

Explanation:

So, aList[0] is 3 and aList[1] is 19, if it will be as it is you litteraly say to the compiler to change aList[0] to aList[1]  at this moment aList[0] is 19 and aList[1] also is 19 and if you try to change aList[1] to aList[0]  it will not change its value because they are the same.

You need temp variable to keep one of the values.

You might be interested in
Consider the following algorithms. Each algorithm operates on a list containing n elements, where n is a very large integer.
DochEvi [55]

We have that the appropriate statement will be

  • An algorithm that accesses only the first 10 elements in the list, regardless of the size of the list. Which of the algorithms run in reasonable time

III only.

Option B

From the question we are told

Consider the following <u>algorithms</u>. Each <u>algorithm</u> operates on a list containing n <em>elements</em>, where n is a very large <u>integer</u>.

I. An algorithm that accesses each <u>element</u> in the list twice.

II. An <em>algorithm </em>that accesses each <u>element </u>in the list n times.

III. An <u>algorithm</u> that accesses only the first 10 elements in the list, regardless of the size of the list. Which of the <em>algorithms </em>run in <em>reasonable </em>time?

<h3>Algorithm  </h3>

Generally In order to get <em>admission </em>to every thing in the list twice, the algorithm has to traverse the listing twice,

which leads to 2*n entry to operations.

And if the every factor is accessed n times, the listing will be traversed n time, which leads to n^2 get right of entry to operations.

If n is a very giant <em>integer</em>, each 2*n and n^2 are plenty larger.

So, there will be <em>solely </em>ten entry to operations and this algorithm will have a sensible jogging time.

Therefore

An algorithm that accesses only the first 10 elements in the list, regardless of the size of the list. Which of the algorithms run in reasonable time

III only.

Option B

For more information on  algorithm  visit

brainly.com/question/950632

4 0
2 years ago
how could environmental and energy problem Kenya faces as far computer installations are concerned be avoided​
ipn [44]

The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

<h3>How can we overcome ICT challenges?</h3>

There are a lot of Energy Challenges in terms of ICT  in Kenyan and it is good the government and the people work towards energy in terms of sustainable ICT.

Therefore, The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

Learn more about computer installations from

brainly.com/question/11430725

#SPJ1

7 0
1 year ago
What is a way of telling the computer how to display certain content pls answer quick
coldgirl [10]
Machine language is the language understood by a computer. It is very difficult to understand, but it is the only thing that the computer can work with. All programs and programming languages eventually generate or run programs in machine language
4 0
3 years ago
g Write a program that prompts the user for an integer n between 1 and 100. If the number is outside the range, it prints an err
grin007 [14]

Answer:

The cpp program is given below.

#include<iostream>

#include<iomanip>

using namespace std;

int main() {

   

   // variables declared

   int n;

   int sum=0;

   float avg;

   

   do

   {

       // user input taken for number    

       cout<< "Enter a number between 1 and 100 (inclusive): ";

       cin>>n;

       

       if(n<1 || n>100)

           cout<<" Number is out of range. Enter valid number."<<endl;

       

   }while(n<1 || n>100);

   

   cout<<" "<<endl;

   

   // printing even numbers between num and 50  

   for(int num=1; num<=n; num++)

   {

       sum = sum + num;

   }

   

   avg = sum/n;

   

   // displaying sum and average

   cout<<"Sum of numbers between 1 and "<<n<<" is "<<sum<<endl;

   cout<<"Average of numbers between 1 and "<<n<<" is ";

   printf("%.2f", avg);

   

       return 0;

}

OUTPUT

Enter a number between 1 and 100 (inclusive): 123

Number is out of range. Enter valid number.

Enter a number between 1 and 100 (inclusive): 56

 

Sum of numbers between 1 and 56 is 1596

Average of numbers between 1 and 56 is 28.00

Explanation:

The program is explained below.

1. Two integer variables are declared to hold the number, n, and to hold the sum of numbers from 1 to n, sum. The variable sum is initialized to 0.

2. One float variable, avg, is declared to hold average of numbers from 1 to n.

3. User input is taken for n inside do-while loop. The loop executes till user enters value between 1 and 100. Otherwise, error message is printed.

4. The for loop executes over variable num, which runs from 1 to user-entered value of n.

5. Inside for loop, all the values of num are added to sum.

sum = sum + num;

6. Outside for loop, average is computed and stored in avg.

avg = sum/n;

7. The average is printed with two numbers after decimal using the following code.

printf("%.2f", avg);

8. The program ends with return statement.

9. All the code is written inside main() and no classes are involved.

3 0
3 years ago
In PowerPoint, a type of chart that, rather than showing numerical data, illustrates a relationship or logical flow between diff
Lynna [10]

Answer:

A. SmartArt

Explanation:

SmartArt is a graphical tool used to visually communicate information.

8 0
3 years ago
Other questions:
  • When using a template to compose a memorandum which key on the keyboard moves the cursor to the next field
    15·1 answer
  • Who is good with Introduction to photography? I don’t know nothing about cameras if you do please contact me ASAP
    13·1 answer
  • . Does Zuckerberg believe in the thought that “the endpoint is when you sell the
    15·1 answer
  • Does learning swift is hard? more than android?
    13·1 answer
  • One common method of converting symbols into binary digits for computer processing is called ASCII​ (American Standard Code of I
    5·1 answer
  • The process where the programmer steps through each of the program's statements one by one is called
    11·1 answer
  • Darcy was working on a presentation on playing chess. Because she chose the Checkerboard animation for her slide title, she had
    15·2 answers
  • An application team plans to follow the 10-phase SDLC model. After the team identifies both functionality and security requireme
    6·1 answer
  • What science category includes physics and biology?
    14·1 answer
  • Is a class of software used to meet organization-wide business needs and typically shares data with other enterprise application
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!