BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/322-object-oriented-programming/)
-   -   Program to enter 10 integers in a single-dimension array and then print out the array in ascending order (http://bzupages.com/f322/program-enter-10-integers-single-dimension-array-then-print-out-array-ascending-order-14669/)

bonfire 09-03-2011 12:23 AM

Program to enter 10 integers in a single-dimension array and then print out the array in ascending order
 
1 Attachment(s)
Program to enter 10 integers in a single-dimension array and then print out the array in ascending order


#include
#include

void main()
{
clrscr();
int array[10],t;
for(int x=0;x<10;x++)
{
cout << "Enter Integer No. " << x+1 << " : " << endl;
cin>>array[x];
}
for (x=0;x<10;x++)
{
for(int y=0;y<9;y++)
{
if(array[y]>array[y+1])
{
t=array[y];
array[y]=array[y+1];
array[y+1]=t;
}
}
}
cout << "Array in ascending order is : ";
for (x=0;x<10;x++)
cout << endl << array[x];
getch();
}
This program takes in the ten integers array[x] to be stored in the single-dimensional array as a screen input from the user.
It then sorts out these ten integers into ascending order and prints them out using the 'cout' command.



Sample Input
43
67
53
21
6
78
92
48
95
8

Sample Output
Array in ascending order is :
6
8
21
43
48
53
67
78
92
95


All times are GMT +5. The time now is 05:38 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.