Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:24:42+00:00 2026-06-13T23:24:42+00:00

This is a simple implementation of a sort algorithm. My question is. The array

  • 0

This is a simple implementation of a sort algorithm. My question is. The array numbers, is declared and initialized in main. Then, I pass it like an argument in the function sort (Is a copy ?). Inside the sort function, numbers, now called array (a copy, as far as I know), is changed (sorted). So, why, after calling the function, the array numbers is changed (this is what I want, buy want to know why??. array scope is in sort, not main.

int main(void)
{
    int numbers[SIZE] = { 4, 15, 16, 50, 8, 23, 42, 108 };
    for (int i = 0; i < SIZE; i++)
        printf("%d ", numbers[i]);
    printf("\n");

    sort(numbers, SIZE);

    for (int i = 0; i < SIZE; i++)
        printf("%d ", numbers[i]);
    printf("\n");
    return 0;
}
void sort(int array[], int size)
{
    int swaps = 0;

    while(swaps==0)
    {
        for(int i = 0; i < size ; i++)
        {
            for(int j = i + 1; j < size ; j++)
            {
                if( array[i] > array[j] )
                {
                    // Swapping
                    int temp = array[i]; 
                    array[i] = array[j];
                    array[j] = temp;

                    swaps ++;
                }   
            }
        }
    }    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:24:43+00:00Added an answer on June 13, 2026 at 11:24 pm

    int array[] is the same as int *array. You are passing a pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was writing an answer to this question when noticed that my simple implementation
I'm reviewing algorithm stuff and stuck in a simple quick sort algorithm implementation in
I have a simple html multiline tooltip implementation: this.tooltip = function(tag) { xOffset =
This simple script should theoretically check the form for errors and then print any
In this simple example, i want to create a String array populated with each
I'm writing a simple linear linked list implementation in PHP. This is basically just
i am implementing the simple bubble sort algorithm using CUDA, and i have a
Alright, so this question isn't exactly about thread management... well, sort of. I am
The implementation of Enumerable.AsEnumerable<T>(this IEnumerable<T> source) simply returns source . However Observable.AsObservable<T>(this IObservable<T> source)
This simple query session = com.jthink.songlayer.hibernate.HibernateUtil.getSession(); Query q = session.createQuery(recNo from SongChanges); giving this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.