Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Sri
Language: C/C++
Code:
#include<iostream.h>
#include<stdio.h>

int main()
{
     
     int arrayElements[] = {45,12,65,34,78,42,74,9};
     int arrayLength = 8;
     for(int loopCount=0;loopCount<arrayLength;loopCount++)
     {
          int minimumValueIndexPosition = loopCount;
          for(int loopCountForAgain=loopCount+1;loopCountForAgain<arrayLength ;loopCountForAgain++)
          {
               if(arrayElements[minimumValueIndexPosition]>arrayElements[loopCountForAgain])
               {
                    minimumValueIndexPosition = loopCountForAgain;
               }
          }
          int temp = arrayElements[loopCount];
          arrayElements[loopCount] = arrayElements[minimumValueIndexPosition];
          arrayElements[minimumValueIndexPosition]=temp;     
     }
     for(int loopCountForSortedArray=0;loopCountForSortedArray<arrayLength ;loopCountForSortedArray++)
     {
          cout<<arrayElements[loopCountForSortedArray];
     }
     return 0;
}

          
          
Comments: