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
Scrat [10]
3 years ago
6

using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles

t, the middle one on the sort list ( in 25 number would bethe 13th number) and the biggest?

Computers and Technology
1 answer:
Umnica [9.8K]3 years ago
4 0

Answer:

C++ code:

#include<iostream>

using namespace std;

void sort(int al[30], int l)

{

//we use insertion sort to sort the array.

int p,q,k;

for(q=1;q<l;q++)   //starting from the 2nd item of the array.

{

 k= al[q];   //taking qth item as key value.

 p=q-1;

 while(p>=0 && al[p]>k)

 {

  al[p+1]=al[p]; //all items those are greaer than al[q] are shifted //to right.

  p=p-1;

 }

 al[p+1]=k;

}

}

int main()

{

int p,l, arrl[30];

cout<<"Enter the number of items in your array: ";

cin>>l;

cout<<endl;

 

cout<<"Enter your "<<l<<" items"<<endl;

for(p=0;p<l;p++)

{

 cin>>arrl[p];

}

 

sort(arrl, l);  //call function sort() to sort the array.

 

cout<<"The array after sorting: ";

for(p=0;p<l;p++)

{

 cout<<arrl[p]<<" ";

}

cout<<endl;

 

cout<<"The smallest item is: ";

cout<<arrl[0]<<endl;

 

cout<<"The middle item is: ";

cout<<arrl[l/2]<<endl;

 

cout<<"The biggest item is: ";

cout<<arrl[l-1]<<endl;

}

Output is given as image.

You might be interested in
so you just gonna bring me a birthday gift on my birthday to my birthday party on my birthday with a birthday gift
Marina86 [1]

Answer:

Happy birthday.?

Explanation:

*GLASS BREAKS*

5 0
3 years ago
Read 2 more answers
List five things that could cause premature bearing failure
Wewaii [24]
Smoking, Drinking, Use of drugs, problems with uterus, Problems with cervix or placenta.


6 0
3 years ago
write a python function that takes string j and returns a dictionary showing number of letters and digits in j. The returned dic
k0ka [10]

Explanation:

def letterDigitCount(j):

dic={"digits":0,"letters":0}

for a in j:

if a.isdigit():

dic["digits"]+=1

elif a.isalpha():

dic["letters"]+=1

return dic

3 0
3 years ago
The Pentium 4 Prescott processor, released in 2004, has a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
Zarrin [17]

Answer:

a) C = 3.2 x 10^-8 F, C = 2.9 x 10^-8 F

b) 10%, 42.86%, 0.11, 0.75

c) 0.849 volts to maintain the same leakage current in the Pentium 4 Prescott Processor. 0.783 Volts to maintain the same leakage current in the Core i5 Ivy Bridge Processor.

Explanation:

<u>For the Pentium 4 Prescott processor:</u>

Clock rate (f) = 3.6 GHz

Voltage (V) = 1.25 V

Static Power Consumption = 10 W

Dynamic Power Consumption = 90 W

<u>For the Core i5 Ivy Bridge processor:</u>

Clock rate (f) = 3.4 GHz

Voltage (V) = 0.9 V

Static Power Consumption (SP) = 30 W

Dynamic Power Consumption (DP) = 40 W

(a) To find the average capacitive loads, use the formula:

DP = (1/2) x C x V² x f

Rearranging:

C = (2 x DP)/(V² x f)

For the Pentium 4 Prescott processor:

C = (2 x 90) / [(1.25)² x 3.6 x 10^9]

C = 3.2 x 10^-8 F

For the Core i5 Ivy Bridge processor:

C = (2 x 40) / [(0.9)² x 3.4 x 10^9]

C = 2.9 x 10^-8 F

(b) Percentage of the total dissipated power comprised by the static power can  be found by the formula:

<u>[Static Power/(Static Power + Dynamic Power)] x 100</u>

For the Pentium 4 Prescott Processor:

[10/(90+10)] x 100  = 10%

For the Core i5 Ivy Bridge Processor:

[30/30+40] x 100 = 42.86 %

Ratio of static power to dynamic power for each technology can be computed as:

Pentium 4 Prescott: 10/90 = 0.11

Core i5 Ivy Bridge: 30/40 = 0.75

(c) The total dissipated power can be calculated by:

P = DP + SP

For Static Power we have the formula:

SP = VI where I is the leakage current.

I = SP/V

For Pentium 4 Prescott: I = 10/1.25 = 8A

For Core i5 Ivy Bridge: I = 30/0.9 = 3.33 A

The total disspited power is reduced by 10%, meaning the ratio of new power to old power must be 90% = 0.9. So,

New Power/Old Power = 0.9

For Pentium 4 Prescott:

DP + SP / 100 = 0.9

VI + CV²F = 0.9 x 100

V(8) + (3.2 x 10^-8)V²(3.6 x 10^9) = 90

8V + 115.2V² - 90 = 0

By solving the quadratic equation, we get the positive answer as 0.849. This means that the voltage should be reduced to 0.849 volts to maintain the same leakage current in the Pentium 4 Prescott Processor.

For Core i5 Ivy Bridge:

DP + SP / 70 = 0.9

V(3.33) + (2.9 x 10^-8)V²(3.4 x 10^9) = 70 x 0.9

3.33V +98.6V² -63 = 0

By solving the quadratic equation we get the positive answer as 0.783. This means that the voltage should be reduced to 0.783 Volts to maintain the same leakage current in the Core i5 Ivy Bridge Processor.

6 0
4 years ago
Why do companies send updates to devices
Luden [163]
To ensure that they are up to date and running smoother than before. Withought updates our devices wouldnt work properly the way they are supposed to!
3 0
3 years ago
Other questions:
  • In this type of network, data is certain to reach its destination.
    7·1 answer
  • The user documents are stored in _______ format.
    15·1 answer
  • Which information is considered free for use?
    9·2 answers
  • Which of the followings is not a testingtype? [2 marks]
    8·1 answer
  • can someone tell me what to do i’m kinda stuck and don’t know what he’s telling me to do pls ill give brainlist and points
    13·1 answer
  • Anyone on ps4 willing to trade me a fennec or McClaren on rocket league?
    6·2 answers
  • The purpose of Appetizers on the menu​
    6·2 answers
  • A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.
    13·1 answer
  • _____ are fields that are used to personalize a mail merge document
    9·1 answer
  • Which of the following is the system of rules and structure governing
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!