Thursday, 24 January 2013

passing array from function as parameter

#include <iostream>

using namespace std;

int modified_array1(int [], int);
int main()
{
    int array1[6];

cout << "enter number to sort out\n";

    for(int i=0; i<6; i++)
    {
        cin >> array1[i];
    }

    modified_array1(array1, 5);

   cout << "Sorted numbers are ";
    for(int j=0; j<5; j++)
    {
        cout << array1[j]<< " ";
    }

cin.get();
return 0;
}



int modified_array1(int array_of_function[], int size)
{

int temp;
   for(int i=0; i<5; i++)
    {
    for(int j=0;j<5-i;j++)

      {
           if(array_of_function[j]<array_of_function[j+1])
           {
           temp = array_of_function[j];
           array_of_function[j] = array_of_function[j+1];
           array_of_function[j+1]=temp;

           }

     }

    }

}


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management