Question

Normal No Spac. Heading 1 Heading 2 se Edit Paragraph Styles Lab 7 Ascending and/or descending array using bubble sort and po


use c program

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include<stdio.h>


void bubbleSort(int *p);

int main()
{
//Assume there are 6 elements of values
int array[5];
int i;
printf("\nEnter 6 elements of an Array: \n\n");
for(i=0;i<6;i++)
{
scanf("%d",&array[i]);
}

bubbleSort(array);


printf("\nSorted Array: \n\n");
for(i=0;i<6;i++)
{
printf("%d\n",array[i]);
}
return 0;
}

void bubbleSort(int *p)
{
int i,j,k;
for(i=0;i<6;i++)
{
for(j=0;j<6-i;j++)
{
if(*(p+j)>*(p+j+1))
{
k=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=k;
}
}
}
}

Output:

Add a comment
Know the answer?
Add Answer to:
use c program Normal No Spac. Heading 1 Heading 2 se Edit Paragraph Styles Lab 7...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • thermodynamics 1 Normal 1 No Spac... Heading 1 Heading 2 Paragraph Styles For each of the...

    thermodynamics 1 Normal 1 No Spac... Heading 1 Heading 2 Paragraph Styles For each of the following cases; find the missing values for each process using first law for that process. (Q, W, E are given in kJ). a) Q=-40; W=?; E1=?; E2=60; AE=? b) Q=?; W= - 90; E1=?; E2=50; AE=0 c) Q=50; W=?; E1=20; E2=?; QE= - 100 |

  • 1 Normal 1 No Spac... Heading 1 Head А Styles Paragraph الكلية الأسترالية في - Lab...

    1 Normal 1 No Spac... Heading 1 Head А Styles Paragraph الكلية الأسترالية في - Lab Worksheet Guidelines alian College of Kuwait Deriment #5: LED I ld the following circuit by using LED and 220, 470, and 1000 ohm's resistors 5V - resistor limits current LED OV Measure the voltage drop cross the LED and then measure the current flowing in the circuit Resistor (92) 220 470 1000 Voltage Drop (volts) 2.02 V 1.94 V 1.89 V Current (Amp) 13mA...

  • BUDUCUDUCUL Styles ay A = D. 1 Normal 1 No Spac... Heading 1 Heading 2 Paragraph...

    BUDUCUDUCUL Styles ay A = D. 1 Normal 1 No Spac... Heading 1 Heading 2 Paragraph 11. Answer the following considering Chargaff's rules. Suppose a 100-base-pair, double- stranded DNA molecule consists of 55% of adenine bases. How many hydrogen bonds in total are holding the two strands together? A. 25 B. 120 C. 200 D. 240 E. That molecule cannot exist in nature

  • AaBbccDc AaBCC AaBbCcc AC 1 No Spac... Heading 1 Heading 2 Titl 1 Normal Paragraph Styles...

    AaBbccDc AaBCC AaBbCcc AC 1 No Spac... Heading 1 Heading 2 Titl 1 Normal Paragraph Styles In an experiment, 50.0 mL of a solution of (CH.CH)NH was titrated with 0.782 M HNO.. the initial pH was 12.98, the pH at the 12 equivalence point was 10.98, and the pH at the equivalence point was 5.80 what is the molarity of the (CH.CH).NH HO

  • LT Normal , 1 No Spac. Heading 1 Heading 2 Subtitle Paragraph Styles What is the...

    LT Normal , 1 No Spac. Heading 1 Heading 2 Subtitle Paragraph Styles What is the difference between broad-spectrum, narrow-spectrum, and selectively-toxic drugs? What is the mode of action of: beta-lactams (penicillin), polymyxins, chloroquines, quinolones, aminoglycosides, tetracyclines, sulfonamides (sulfa drugs), synthetic azoles What mechanisms of resistance do bacteria actually gain from resistance genes? (hint: there are What is a superinfection? What is the difference between a Kirby-Bauer susceptibility test, E-test diffusion test and tube dilution test? What do they have...

  • T Normal T No Spac.. Heading 1 Heading 2 Styles Paragraph 2 Chapter 3 Problem and...

    T Normal T No Spac.. Heading 1 Heading 2 Styles Paragraph 2 Chapter 3 Problem and Applications Maria can read 20 pages of economics in an hour. She can also read 50 pages of sociology in an hour. She spends 5 hours per day studving. 1. Draw Maria's production possibilities frontier for reading economics and sociology What is Maria's opportunity cost of reading 100 pages of sociology? a. b.

  • AaBbCcDc AaBbCcDc AaBbc 1 Normal 1 No Spac... Heading 1 EEEEE Paragraph Styles PICCOT question In...

    AaBbCcDc AaBbCcDc AaBbc 1 Normal 1 No Spac... Heading 1 EEEEE Paragraph Styles PICCOT question In prostate cancer patients with a Gleason score of 6 or above (P), how does radiation (1) compared to having a prostatectomy(C) on clinical response rate and overall survival (O). 1:What method would be use to purpose the research topic above 2:What sample would be use to purpose the research topic above 3: How would you conduct a different research study to impact the issue...

  • 1 Normal AaBbccl 1 No Spac... Heading 1 Heading 2 Title Paragraph Styles Aqueous solutions of...

    1 Normal AaBbccl 1 No Spac... Heading 1 Heading 2 Title Paragraph Styles Aqueous solutions of sodium phosphate and calcium chloride react Procedure: 1. Obtain a well plate 2. Add several drops of sodium phosphate and several drops of calcium chloride to a single well. • What do you observe? (2) • Write a balanced chemical reaction including states of matter (12) Na3PO4 +CaCl2 → Ca3(PO4)2 + Naci • Identify the reaction type and explain your reasoning (2) Double Replacement....

  • 1 Normal 1 No Spac... Heading 1 Heading 2 Title Paragraph Styles Topic: Comparing firms using...

    1 Normal 1 No Spac... Heading 1 Heading 2 Title Paragraph Styles Topic: Comparing firms using ratio analysis LO: 5 7. Consider the following 2016 data for two manufacturing firms (S in millions): Cherokee Industries Guinea Company Average Current Liabilities $57,200 89,600 Cash from Operations $40,640 118.000 Expenditures on PPE $7,600 12,400 Dividends cash $17,200 31,600 a. Compute the operating cash flow to current liabilities ratio for each firm for 2016. b. Compute the operating cash flow to capital expenditures...

  • AaBCCL АаВЫСcl AaBbC A- erA T Normal I No Spac... Heading 1 Н Paragraph IN Styles...

    AaBCCL АаВЫСcl AaBbC A- erA T Normal I No Spac... Heading 1 Н Paragraph IN Styles Calculate F, and for the beam shown below. The beam has a mass of 500 kg. 1500 N 2050 N * 6m F2 I

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT