Thread: Need HUGE help

  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
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 03-02-2011, 07: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, 12:06 PM
  5. near, far , huge pointers in linux.
    By quickNitin in forum C++ Programming
    Replies: 6
    Last Post: 08-29-2006, 08:40 AM