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
ANEK [815]
3 years ago
6

Langauge: C++Make absolutely no changes to main(). Change function backwards so that the elements of the array are swapped in or

der for elements to be in reverse order. That is, arr[0] will be 16, arr[1] will be 5, etc. But backwards() must work no matter what values are in the array and for all values passed in for number. After it is corrected this program should output:16531782#include using namespace std;void backwards(int [], int);int main(){int arr[] = {2,8,17,3,5,16}; int i;backwards(arr,6);for (i = 0; i< 6; i++)cout<
Computers and Technology
1 answer:
Amiraneli [1.4K]3 years ago
4 0

Answer:

#include <iostream>

using namespace std;

void backwards(int [], int);

int main()

{

int arr[] = {2,8,17,3,5,16}; int i;

backwards(arr,6);

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

cout<<arr[i]<<endl;

//system("pause");

return 0;

}

void backwards(int array[], int number)

{

/*Pre: array[] - array of integers

number - number of elements in the array that have values

Post: Nothing

Purpose: Reverse the order of the elements of an array */

int i; int temp;int j;

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

{

temp = array[i];

array[i] = array[number - 1 - i];

array[number - 1 - i]=temp; // Just change is needed here, the assignment was wrong rest all is ok.

}

return;

}

You might be interested in
A detective agency is looking to bust an arms sale. According to available intelligence, the sale is likely to happen in one of
Paha777 [63]

Answer:

Probability Distribution={(A, 4/7), (B, 2/7), (C, 1/7)}

H(X)=5.4224 bits per symb

H(X|Y="not C")=0.54902 bits per symb

Explanation:

P(B)=2P(C)

P(A)=2P(B)

But

P(A)+P(B)+P(C)=1

4P(C)+2P(C)+P(C)=1

P(C)=1/7

Then

P(A)=4/7

P(B)=2/7

Probability Distribution={(A, 4/7), (B, 2/7), (C, 1/7)}

iii

If X={A,B,C}

and P(Xi)={4/7,2/7,1/7}

where  Id =logarithm to base  2

Entropy, H(X)=-{P(A) Id P(A) +P(B) Id P(B) + P(C) Id P(C)}

=-{(1/7)Id1/7 +(2/7)Id(2/7) +(4/7)Id(4/7)}

=5.4224 bits  per symb

if P(C)  =0

P(A)=2P(B)

P(B)=1/3

P(A)=2/3

H(X|Y="not C")= -(1/3)Id(I/3) -(2/3)Id(2/3)

=0.54902 bits per symb

4 0
3 years ago
What is the difference between a queue and a stack?
Zinaida [17]

Answer:

Difference between Queue and Stack are as following:-

  1. Queue is a FIFO(First In First Out) type data structure while Stack is a LIFO(Last In First Out) type data structure.
  2. The insertion and deletion of elements from the queue happens from two ends insertion at the tail and deletion from the front.While the insertion and deletion from stack happens from one end only that is top.
  3. The insertion and deletion operation in queue are referred as enqueue and dequeue. While in stack they are referred as push and pop respectively.
7 0
4 years ago
Processor speeds are in bytes.<br><br> True<br> or<br> False
Aneli [31]

Answer:

true

Explanation:

Mainly true, but partly false. There are two bits in a computer that supply speed: The processor (measured in hertz eg. 2Ghz Processor) and RAM (bits and bytes eg 2GB of RAM). The processor is more to do with the speed programs run and load at, and RAM let's you use lots of memory intensive programs at the same time, although this also comes down to the processor and vice versa. Hope I helped :)

5 0
3 years ago
Read 2 more answers
What can I play to get max points
BaLLatris [955]

Answer:

H o e! (as the gardening tool)

3 0
3 years ago
Read 2 more answers
To save a new copy of an existing database, a user can open the original database and select ________ from the file tab.
Yuri [45]
And select copy from the file tab.
6 0
3 years ago
Other questions:
  • Write a program to help you feed your friends at a party by doing some math about square pizzas. Assume the grader defines a str
    12·1 answer
  • What is the net stop command that will disconnect all share connections to the local PC?
    5·1 answer
  • Harry wants to change the background of all of his presentation slides. Which slide will enable him to make this change to all t
    14·1 answer
  • What is an icon or animation used to represent a participant in an internet chat referred to as
    15·2 answers
  • Maggie is preparing a document.she wants to open the help menu to sort out a formatting problem.which key should she press to op
    15·2 answers
  • What analogy could you use to explain the hardware parts of a computer?
    11·1 answer
  • Write a function that, given an array A of N integers, of which represents loads caused by successive processes, the function sh
    15·1 answer
  • A computer scientist creates an app that tells you a funny joke each time you touch the Joke button.
    15·1 answer
  • What type of platform is Twitter?
    10·2 answers
  • A server malfunction has been resolved after replacing a failed hard drive. Enterprise services have been restored. What is the
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!