Program to print the number in ascending order
#include <iostream>
#include <conio.h>
void main ()
{
clrscr();
int array [3], t;
for (int x=0; x<3; x++)
{
cout << "Enter integer number" << x+1 << " : " << endl;
cin<< array[x];
}
for (x=0; x<3; x++)
{
for (int y=0; y<2; y++)
{
if(array[y]>array[y+1])
{
t=array[y];
array[y]=array[y+1];
array[y+1]=t;
}
}
}
cout << "The integers in ascending order are : ";
for (x=0;x<3;x++)
cout << endl << array[x];
getch();
}
#include <iostream>
#include <conio.h>
void main ()
{
clrscr();
int array [3], t;
for (int x=0; x<3; x++)
{
cout << "Enter integer number" << x+1 << " : " << endl;
cin<< array[x];
}
for (x=0; x<3; x++)
{
for (int y=0; y<2; y++)
{
if(array[y]>array[y+1])
{
t=array[y];
array[y]=array[y+1];
array[y+1]=t;
}
}
}
cout << "The integers in <strong class="highlight">ascending</strong> order are : ";
for (x=0;x<3;x++)
cout << endl << array[x];
getch();
}
Comments
Post a Comment