Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   problems in c++ . (http://www.go4expert.com/forums/problems-in-cpp-t25292/)

it-girl 18Mar2011 20:55

problems in c++ .
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 .

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 .

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 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;            }        }    } 

after this i have other question :D

xpi0t0s 21Mar2011 02:06

Re: problems in c++ .
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.

#include <iostream.h>
void bubble_sort(int Array[ ],int  ,int  );
void main()
    int n_elements,temp=0,Array[50];
    cout<<"How many elements ? ";
    cout<<"Enter the elements:-\n";
    for(int i=0;i<n_elements;i++)
    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])

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.

All times are GMT +5.5. The time now is 22:18.