Like Tree1Likes

Need HUGE help

This is a discussion on Need HUGE help within the C Programming forums, part of the General Programming Boards category; Alright, let's narrow it down is the problem: 1) Because the data in the grades array isn't what you need, ...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Alright, let's narrow it down is the problem:

    1) Because the data in the grades array isn't what you need,

    or

    2) Is the data in the array OK, but the display in the showgrades() function, is not working right?

    Shouldn't getgrades have an int return type?

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    For starters, you should indent your code properly, e.g.,
    Code:
    getgrades(double *grades)
    {
        double temp;
        system("cls");
        printf("Enter Grades\n\n");
    
        for(count = 0; count < 100; count++)
        {
            printf("Enter Grade or Press 0 to Exit: ");
            scanf("%lf*c", &temp);
            if (temp == 0)
            {
                break;
            }
            else
            {
                temp = grades[count];
            }
        }
    
        getchar();
        return(count);
    }
    
    void showgrades(double *grades, int count)
    {
        system("cls");
        int i;
    
        printf("Inputed Grades");
        printf("\n\nPosition_______Grade\n");
        for(i=0; i<count; i++)
        {
            printf("%d%20.2lf\n", i+1, *(grades+i));
        }
        printf("\n\nPress Enter to Continue");
        getchar();
    }
    Next, you should tell us what's not working for you.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Registered User
    Join Date
    Mar 2011
    Posts
    19
    I'm thinking it's a problem with the display in the showgrades function. And you are right, you getgrades should have been an int. I changed that. Thank you.

    But I'm really not sure if it is the array itself not actually having the numbers or whether it's how i'm trying to call them in the showgrades funtion.

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You aren't really very helpful. Don't say "I have a problem" without telling us what it is.
    Code:
    void foo( int a[], size_t s )
    {
        size_t x;
        for( x = 0; x < s; s++ )
            a[ x ] = x;
    }
    
    void bar( int a[], size_t s )
    {
        size_t x;
        for( x = 0; x < s; s++ )
            printf( "%d\n", a[ x ] );
    }
    
    int main( void )
    {
        int a[5];
        foo( a, 5 );
        bar( a, 5 );
        return 0;
    }
    What does that do that your program doesn't?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You aren't really very helpful. Don't say "I have a problem" without telling us what it is.
    Code:
    void foo( int a[], size_t s )
    {
        size_t x;
        for( x = 0; x < s; s++ )
            a[ x ] = x;
    }
    
    void bar( int a[], size_t s )
    {
        size_t x;
        for( x = 0; x < s; s++ )
            printf( "%d\n", a[ x ] );
    }
    
    int main( void )
    {
        int a[5];
        foo( a, 5 );
        bar( a, 5 );
        return 0;
    }
    What does that do that your program doesn't?


    Quzah.
    Hope is the first step on the road to disappointment.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 03-02-2011, 06:35 PM
  2. Huge string manipulation problem.
    By jadaces in forum C Programming
    Replies: 24
    Last Post: 07-14-2010, 12:54 PM
  3. near, far and huge pointers
    By roaan in forum C Programming
    Replies: 14
    Last Post: 08-27-2009, 05:15 PM
  4. Calculating prime factor of a huge number.
    By Bakster in forum C Programming
    Replies: 15
    Last Post: 02-20-2009, 11:06 AM
  5. near, far , huge pointers in linux.
    By quickNitin in forum C++ Programming
    Replies: 6
    Last Post: 08-29-2006, 08:40 AM

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