C++ Program to Sort a set of Numbers in Ascending Order - with Visualized Program Process Flow

preview_player
Показать описание
Creating a Strong foundation for Programmers & Geeks. Learn from scratch. Evolve your Career.

Our aim is to create a strong foundation at root level programming so that it helps any layman to evolve into a highly efficient programmer.

Learn to write C++ code on "How to SORT a set of Numbers in Ascending Order" - with the help of a Program driven by "visualized program tracking". You are guided by well researched, effortless teaching process, that has helped create a strong foundation for several aspiring software engineers.
Рекомендации по теме
Комментарии
Автор

#include <iostream>
using namespace std;
int main()
{
int n, i, j, temp, a[10]; char choice;

cout << "How many numbers would you enter ? "; cin >> n;
cout << "Enter " << n <<" numbers :\n";
for ( i=0 ; i<n ; ++i)
cin >> a[i];

for ( i=0 ; i < n-1 ; ++i )
for ( j = i+1 ; j<n; ++j )
if ( a[ i ] > a[ j ])
{
temp = a[ i ] ;
a[ i ] = a[ j ];
a[ j ] = temp;
}

cout << "Sorted List (ascending order) \n";
for ( i=0 ; i<n ; ++i)
cout<<a[i]<<"\n";
}

Technocratajitsaigal