Sample – Program to enter 10 integers in a single-dimension array and then print out the array in ascending order.
by Nideesh C on February 8, 2011 · 0 comments
in C++
#include <iostream.h>
#include <conio.h>
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.
Not Satisfied ? Just search & get the result
Related posts:
- Sample – Program to enter two integers and print the quotient and remainder.
- Sample – Program to enter three integers and output the biggest integer.
- Sample – Program to enter three integers and output the biggest integer using IF
- Sample – Program to enter an integer and print out its successor.
- Sample – Program to print the first 10 lines of pascal’s triangle.
Tagged as:
c programming examples,
c programming reference,
c tutorial,
c++ program examples,
C++ Programming,
learning c++,
Program to enter 10 integers in a single-dimension array and then print out the array in ascending order.,
programming languages,
programming languages c,
sample c++ programs
Me, freelance system administrator having the qualification of Diploma in Electronics & Tele-communication + MCSE + CCNA + CST + 5 years of experience in IT field.
If you like This post, you can follow TheOnlineTutorials on Twitter.
Contact me Via email: support@theonlinetutorials.com
Subscribe to feed via Feed or EMAIL to receive instant updates.
Legal Disclaimer:All information found on the site is without any implied warranty of fitness for any purpose or use whatsoever. Content author/site administrator is not responsible for any loss occurred due to mistakes in this tutorial. Use this tutorial website at your own risk.