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 8586141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:14:20+00:00 2026-06-11T22:14:20+00:00

That is my function: int main() { double data[100]; int num; cout<<num= ; cin>>num;

  • 0

That is my function:

int main() {
    double data[100];

    int num;

    cout<<"num= ";
    cin>>num;

    for(int i = 1; i <= num; i++) {
        cout<<i<<" element = ";
        cin>>data[i];
    }

    Sort(data, num);

    for (int i = 1; i <= num; i++) {
        cout<<data[i]<<endl;
    }

    return 0;
}

void Sort(double data[], int n) {
    int i,j,k;
    double min;

    for(i = 0; i < n-1; i++) {
        k = i;
        min = data[k];

        for(j = i+1; j < n; j++)
            if(data[j] < min) {
                k = j;
                min = data[k];
            }
        data[k] = data[i];
        data[i] = min;
    }
}

if I write for exp. three elements: 8,9,1 again cout 8,9,1?

  • 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-11T22:14:21+00:00Added an answer on June 11, 2026 at 10:14 pm
    for(int i = 1; i <= num; i++) { // WRONG
    

    I think you mean:

    for(int i = 0; i < num; i++) { // RIGHT
    

    Arrays in C are 0-indexed remember.

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

Sidebar

Related Questions

I'm reading some C code like that: double function( int lena,double xa,double ya, double
Assume the following function prototype: void *function(int arg) . Is that a pointer to
I have a function that creates a 2D vector void generate(int n) { vector<
how to remove function that bound to member function of this object : std::vector<std::function<void(int)>>
I have a C function int func( int a, int* b) that I need
If I have a function that produces a result int and a result string
I have a fitness function that is scoring the values on an int array
I have a constexpr function that looks something like this: constexpr int foo(int bar)
I know that a function pointer stores the address of a function. int fun(int
Here is a simple function that converts a string to an integer. int str2int(char

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.