SlideShare a Scribd company logo
Write a C++ program that searches through an array and finds the biggest number and outputs it
to the screen
Solution
sort.cpp
Program to sort an array in ascending order in c++
To compile (Need g++ compiler for unix/linux or Microsoft compiler for windows)
g++ sort.cpp -o sort
*/
#include<iostream>
using namespace std;
int main()
{
//declare array of type integer
int a[20],i,j,temp;
//Input the ten numbers and save them in an array.
for(i=0;i<5;i++)
{
cout<<"Enter the "<<i<<" no.to sort:";
cin>>a[i];
}
//sort the array
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
//Print the array.
for(i=0;i<5;i++)
cout<<a[i]<<endl;
}

More Related Content

More from richard981

Why might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docxWhy might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docx
richard981
 
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docxWhy might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
richard981
 
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docxWhy lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
richard981
 
Why might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docxWhy might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docx
richard981
 
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docxWhy is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
richard981
 
Why is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docxWhy is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docx
richard981
 
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docxWhy does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
richard981
 
why is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docxwhy is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docx
richard981
 
Why is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docxWhy is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docx
richard981
 
Why is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docxWhy is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docx
richard981
 
why EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docxwhy EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docx
richard981
 
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docxWhy is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
richard981
 
why does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docxwhy does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docx
richard981
 
Why does iodine have a much lower melting point than sodium iodide- W.docx
Why does iodine have a much lower melting point than sodium iodide-  W.docxWhy does iodine have a much lower melting point than sodium iodide-  W.docx
Why does iodine have a much lower melting point than sodium iodide- W.docx
richard981
 
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docxWhy do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
richard981
 
Why does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docxWhy does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docx
richard981
 
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docxWhy do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
richard981
 
Why does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docxWhy does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docx
richard981
 
Why do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docxWhy do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docx
richard981
 
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docxWhy do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
richard981
 

More from richard981 (20)

Why might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docxWhy might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docx
 
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docxWhy might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
 
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docxWhy lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
 
Why might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docxWhy might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docx
 
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docxWhy is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
 
Why is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docxWhy is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docx
 
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docxWhy does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
 
why is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docxwhy is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docx
 
Why is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docxWhy is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docx
 
Why is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docxWhy is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docx
 
why EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docxwhy EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docx
 
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docxWhy is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
 
why does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docxwhy does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docx
 
Why does iodine have a much lower melting point than sodium iodide- W.docx
Why does iodine have a much lower melting point than sodium iodide-  W.docxWhy does iodine have a much lower melting point than sodium iodide-  W.docx
Why does iodine have a much lower melting point than sodium iodide- W.docx
 
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docxWhy do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
 
Why does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docxWhy does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docx
 
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docxWhy do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
 
Why does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docxWhy does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docx
 
Why do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docxWhy do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docx
 
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docxWhy do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
 

Recently uploaded

MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

Write a C++ program that searches through an array and finds the bigge.docx

  • 1. Write a C++ program that searches through an array and finds the biggest number and outputs it to the screen Solution sort.cpp Program to sort an array in ascending order in c++ To compile (Need g++ compiler for unix/linux or Microsoft compiler for windows) g++ sort.cpp -o sort */ #include<iostream> using namespace std; int main() { //declare array of type integer int a[20],i,j,temp; //Input the ten numbers and save them in an array. for(i=0;i<5;i++) { cout<<"Enter the "<<i<<" no.to sort:"; cin>>a[i]; } //sort the array for(i=0;i<5;i++) { for(j=0;j<5;j++) { if(a[i]<a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } }