problems in c++ .

Discussion in 'C++' started by it-girl, Mar 18, 2011.

  1. it-girl

    it-girl New Member

    Joined:
    Mar 18, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi .

    i want you to help me to solve my problems .
    i start now to study c++ by myself .
    i am intersted with programming .

    i coded many programs .
    but its still there errors that i didnt understand it .

    1/
    who can write this code .
    my idea is i should be their two function the first is to sort the array aompare the elements .
    and other function is to chick if there mode or not
    if any one can explain ..
    because i did't study the sorting until now .


    2
    the median of an array of numbers is the element m of the array such that half the remaining numbers in the array are greater than or equal to m and half are less than or equal to m . if the numbers of elements in the array is odd . if the number of elements is even .the median is the average of the two elements m1 and m2 , such that half the remaining elements are greater than or equal to m1,m2 and half the elements are less than or equal to m1,m2 . write a c function that accepts an array of numbers and return the median of the numbers in the array

    what the mean of median ?


    i write the function that insert with bubble ,
    but waht the mode .

    PHP:
    #include <iostream.h>void bubble_sort(int Array[ ],int  ,int   );void main(){int n_elements,temp=0,Array[50];    cout<<"How many elements ? ";    cin>>n_elements;    cout<<"Enter the elements:-\n";    for(int i=0;i<n_elements;i++)        cin>>Array[i];bubble_sort(Array,n_elements,temp);    chick ( Array, n_elements);}void bubble_sort(int Array[],int n_elements,int temp){         for(int i=0;i<n_elements;i++)        {            for(int j=0;j<n_elements;j++)            {                if (Array [i]<Array[j]){                temp=Array[i];                Array[i]=Array[j];                Array[j]=temp;            }        }    }

    after this i have other question :D
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Well here's your code reformatted, and there is a very obvious problem with it at the end. Use correct formatting and you won't get this kind of problem.
    Code:
    #include <iostream.h>
    void bubble_sort(int Array[ ],int  ,int   );
    void main()
    {
        int n_elements,temp=0,Array[50];
        cout<<"How many elements ? ";
        cin>>n_elements;
        cout<<"Enter the elements:-\n";
        for(int i=0;i<n_elements;i++)
        cin>>Array[i];
        bubble_sort(Array,n_elements,temp);
        chick ( Array, n_elements);
    }
    
    void bubble_sort(int Array[],int n_elements,int temp)
    {    
        for(int i=0;i<n_elements;i++) 
        {  
            for(int j=0;j<n_elements;j++)
            {
                if (Array [i]<Array[j])
                {    
                    temp=Array[i];
                    Array[i]=Array[j];
                    Array[j]=temp;
                } 
            }
        }  
    
    Anyway, I've tried looking into the holes in my monitor, and behind it, and I still can't see your screen. Tried reading your mind too but for some reason I couldn't get through.

    So could you post the errors you get please?

    You can find the meaning of median with Google; you don't have to ask here.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice