Sunday, 18 January 2015

Sorting array of length N with ascending and descending order using For loops in C++


#include
using namespace std;
int main()
{
     int n; // variable for storing array size
     cout<<"Array Size :";
     cin>>n; // input array size.
     int array[n]; // declare array of size (n). i.e=10
     int temp=0;  // temporary variable
   
     /* Input All N numbers of array */
     for(int i=0;i>array[i];    
     }
   
     /*Printing the original array */
     cout<<"\n\n\t\t Original Array\n";
     for(int i=0;iarray[j+1]) // sorting
         {
             temp=array[i];
             array[i]=array[j+1];
             array[j+1]=temp;
         }
       }
     }
   
     /*Printing the sorted ascending order array */
     cout<<"\n\n\t\t sorted ascending order array\n";
     for(int i=0;i
// Run this code using devC++.

====================
TCC | The Complete Code
====================

0 comments:

Post a Comment