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
LiRa [457]
3 years ago
5

Write a program that implement a bubble sort ?

Computers and Technology
1 answer:
Tanzania [10]3 years ago
6 0

Answer:

 A program that implement a bubble sort:

 #include<iostream.h>

 #include<conio.h>

 

int main()

{

int ar[50],no,i,j,temp;

cout<<"Enter array size ";

cin>>no;

cout<<"Enter array elements ";  

 

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

 cin>>ar[i];

 

for(i=1;i<no;++i)

{

 for(j=0;j<(no-i);++j)

  if(ar[j]>ar[j+1])

  {

   temp=ar[j];

   ar[j]=ar[j+1];

   ar[j+1]=temp;

  }

}

 

cout<<"Bubble Sort array";

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

 cout<<" "<<ar[i];

 

return 0;

}

You might be interested in
Henry is creating code In JavaScript to run calculations on extremely small numbers. How can he use MIN_VALUE as validation in t
QveST [7]

In creating code in JavaScript to run calculations on extremely small numbers, MIN_VALUE as validation in the program can be use to check the lowest value JavaScript can handle

Number.MIN_VALUE returns the smallest positive numeric value representable in JavaScript.  It is the number more closer to zero. The value is approximately 5e⁻³²⁴.

Using Number.MIN_VALUE, the value can be printed as follows:

val = Number.MIN_VALUE;

console.log(val); // 5e-324

Therefore, In creating code in JavaScript to run calculations on extremely small numbers, MIN_VALUE as validation in the program can be use to check the lowest value JavaScript can handle.

learn more on JavaScript here: brainly.com/question/13041378?referrer=searchResults

3 0
2 years ago
"write a program to play and score the paper-rock-scissor game. each of two users types in either p, r, or s. the program then a
algol13

The program is an illustration of conditional statements.

Conditional statements are used to execute instructions, if and only if certain <em>condition or conditions </em>are met.

Take for instance: <em>If b = 5, print "ab"</em>

The above print statement will only be executed, if the <em>value of b is 5</em>

The paper-rock-scissor program in Python where comments are used to explain each line is as follows,  

#This imports the random module

import random

#This is used to control the repetition of the game

playagain ="T"

#The following is repeated until the user chooses not to play again

while(playagain == "T"):

   #This generates a random choice for the computer

   computer = random.choice(['Rock', 'Paper', 'Scissors'])

   #This gets input for the player

   player = input('Choose: ')

   #If the player and computer choose the selection

   if player == computer:

       #Then, it's a tie

       print('A tie - Both players chose '+player)

   #If the player wins

   elif (player.lower() == "Rock".lower() and computer.lower() == "Scissors".lower()) or (player.lower() == "Paper".lower() and computer.lower() == "Rock".lower()) or (player == "Scissors" and computer.lower() == "Paper".lower()):

       #This prints "player won" and the reason

       print('Player won! '+player +' beats '+computer)

   #If otherwise,

   else:

       #This prints "computer won" and the reason

       print('Computer won! '+computer+' beats '+player)

   #This asks if the player wants to play again

   playagain = input("Play again? T/F: ")

At the end of each round,

  • The program displays the winner
  • Or prints a tie, if there's a tie

See attachment for sample run

Read more about conditional statements at:

brainly.com/question/22078945

8 0
2 years ago
In HTML, an opening tag and its closing tag must appear on the same line. True Or False​
DaniilM [7]

Answer:

the answer is true, you cannot break the element apart EVERR!!!!!

3 0
2 years ago
6. Which hypothesis about the fate of the universe says that it will expand continuously as the galaxies drift far apart and all
zaharov [31]
A. The big bang theory
6 0
3 years ago
If a node has a wireless connection to the internet, does that node have to be mobile
Marizza181 [45]
No it does not . answers
8 0
3 years ago
Other questions:
  • Your company is developing a new marketing campaign and wants to know which customers have never placed an order. You will need
    10·1 answer
  • What is intensity? this is for digital arts
    12·1 answer
  • A(n) _____ bus enables the central processing unit (CPU) to communicate with a system’s primary storage.
    5·1 answer
  • Which of the following was the name of the first generation of cell phone networks?
    14·1 answer
  • Describe the 3 different types of authentication
    6·2 answers
  • Hulu suggestions? I just got it and I wanna know what's good :)
    5·2 answers
  • Project manager George is defining project management to his team. How should he define project management in one sentence?
    7·1 answer
  • 1. A database table can hold ??
    9·1 answer
  • How many characters does the "short text" have?
    9·1 answer
  • Sự ra đời của thương mại điện tử có tác động như thế nào đến việc quảng cáo và Marketing sản phẩm
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!