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
777dan777 [17]
4 years ago
11

Write a program in C++ to implement bubblesort using the swap function ?

Computers and Technology
1 answer:
marishachu [46]4 years ago
3 0

C++ program for implementation of Bubble sort  

#include <bits/stdc++.h>  

using namespace std;  

 void swap(int *x, int *y)  /*Defining Swap function of void return type*/

{  

  int temp = *x;  //Swaping the values  

   *x = *y;  

   *y = temp;  

}  

void bubbleSort(int array[], int n) /*Defining function to implement bubbleSort  */

{  

  int i, j;  

  for (i = 0; i < n-1; i++)      

      for (j = 0; j < n-i-1; j++)  /*The last i components are already in location  */

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

          swap(&array[j], &array[j+1]);  //Calling swap function

}  

int main()  //driver function

{  

   int array[] = {3, 16, 7, 2, 56, 67, 8}; //Input array  

   int n = sizeof(array)/sizeof(array[0]);  //Finding size of array

   bubbleSort(array, n); //Function calling  

   cout<<"Sorted array: \n";  

   for (int i = 0; i < n; i++)  //printing the sorted array

       cout << array[i] << " ";  

   cout << endl;  

 return 0;  

}  

<u>Output</u>

Sorted array:  

2 3 7 8 16 56 67

You might be interested in
Ancler Corporation wants to calculate how much their profits were in the first quarter of the year. They should use a
Wewaii [24]

They should use a spreadsheet.

Explanation:

With a spreadsheet all they will need to do is to give formula to the cells and any time they key in the expenses and revenue figures they are going to get their profit for the quarter.

It is more convenient and reliable. It reliefs the user of computation issues.

6 0
3 years ago
Read 2 more answers
DPI stands for _____.
antiseptic1488 [7]
Dots Per Inch
JPEG (or jpg)
For img tags, the ALT attribute. It's also very important for text readers for the visually impaired.
5 0
4 years ago
What controls network connectivity such as Wi-Fi and the GPS locator in a mobile device?
MakcuM [25]

Answer:

There are hybrid system that consist of WiFi, GPS, GSM and IP address to locate the mobile devices.

Explanation:

In Cellular phone communication, hybrid technique is used to locate to find the locations. It consist of WiFi, GSM, GPS and IP addresses. GPS technology is used with satellite communication. Location has been sent from satellite to the mobile network with the help of Google maps. There are few other techniques used to such as GSM based techniques that is used by the help of radio signals strength to find the location of the device. This technique is helpful in the areas where the many communication tower are there to locate the signal strength in the area of the mobile device. WiFi also used to locate the mobile device with the help of IP addresses.

In mobile phones, different combinations of all above technologies used to provide the network connectivity such as WiFi and GPS locator in the mobile Phone.  This is called Cellular locating technology.

5 0
3 years ago
Which function returns the rank of a value within a dataset, assigning an average rank for tied values
ANTONII [103]
Z-y bcuz it is a function and u need to revail rate
4 0
3 years ago
________ systems help supervisors by generating databases that act as the foundation for other information systems. Group of ans
Dahasolnce [82]

Answer:

1. Decision support systems

Explanation:

DSS (Decision Support Systems) are systems that provide supports for decisions, judgments and analysis in an organization. They help in solving problems and in decision-making. With DSS, databases that act as foundation for other information systems can be generated for supervisors helping them to make logical analysis of a particular problem hence solving it.

DSS will actually not give the decision, but will guide the decision maker in making the decision by helping to gather raw facts and useful models which enhance decision making.

6 0
4 years ago
Other questions:
  • Why should you use a named constant for the size of an array?
    9·1 answer
  • Can somebody help me with this problem
    10·1 answer
  • Hi weegy, what is the latest android os?
    9·1 answer
  • A common use-case for dictionaries is to store word counts. Let's modify our program below to store the count for each unique wo
    9·1 answer
  • I NEED answers for these qu plz
    5·1 answer
  • What happens if none of the selector values match selector in a simple case expression in pl/sql
    6·1 answer
  • Focusing on a target market makes it harder to develop products and services that specific groups of customers want.
    10·1 answer
  • Write a script that checks to see if at least one argument has been given on the command line and tests whether the argument is
    5·1 answer
  • HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP!!!
    12·1 answer
  • Tick (/) the correct answers.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!