sorting program

This is a discussion on sorting program within the C Programming forums, part of the General Programming Boards category; I need to make sorting program with out using array, Sort commend. I must use pointers, call by reference, and ...

  1. #1
    jk
    Guest

    sorting program

    I need to make sorting program with out using array, Sort commend.
    I must use pointers, call by reference, and call by value.
    I didn't finish the rest of the part, since there's something wrong with my function call.
    I think my function call for read5 is wrong, but I don't know how to fix. Since, I have to make function read5 to get input.
    How can I make function call for read 5?



    /* Program that utilizes simple functions illustrating call-by-reference and call-by-valye */

    #include <stdio.h>

    double read5(double*, double*, double*, double*, double*);
    double sort5(double*, double*, double*, double*, double*);
    double print5(double*, double*, double*, double*, double*);

    int main(void)
    { /* begin main */
    /* Declaration */
    int checknum = 1;

    /* Check Scanf */
    while(checknum > 0)
    { /* start while */
    if (checknum == 0)
    { /* begin if */
    printf("Ends Program");
    checknum = -1;
    } /* end if */
    else
    { /* begin else */
    checknum = read5(double*, double*, double*, double*, double*);
    sort5(double*, double*, double*, double*, double*);
    print5(double*, double*, double*, double*, double*);
    } /* end else */

    } /* end while */

    }


    double read5(double *i, double *j, double *k, double *l, double *m)
    {
    int check;

    check = scanf(&i, &j, &k, &l, &m);
    return check;
    }

    } /* end read5 */

    double sort5(double *u, double *v, double *w, double *x, double *y)
    {
    int count, count2, count3;
    double numsave, numsave2, numsave3, numsave4;

    for(count=0; count <= 10; ++count)
    {
    if(u <= v)
    {
    numsave = *u;
    }
    else
    {
    numsave = *v;
    }

    if(w<=x)
    {
    numsave2 = *w;
    }
    else
    {
    numsave = *x;
    }


    }
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    If you're reading into an address that is already a pointer, using the scanf functions, just use its name without the address-of operator:
    Code:
    void read( double *ptr1, double *ptr2, double *ptr3, double *ptr4 )
    {
        printf("Enter four floating point numbers: ");
        scanf( "%f %f %f %f", ptr1, ptr2, ptr3, ptr4 );
    }
    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 08:51 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21