Lecture 120
// Loop do while
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
int n,a[5];
cout<<"Initialisation array:\n ";
n=0;
do
{
cout<<"Enter the number: ";
cin>>a[n];
n++;
}while(n<5);
cout<<"Print the array :\n";
n=0;
do
{
cout<<a[n]<<endl;
n++;
}while(n<5);
cout<<"Print the sort array :\n";
int i,j,a1;
i=0;
do{
j=i;
do
{
if(a[i]>a[j])
{
a1=a[i];
a[i]=a[j];
a[j]=a1;
}
j++;
}while(j<5);
i++;
}while(i<5);
n=0;
do
{
cout<<a[n]<<endl;
n++;
}while(n<5);
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10