Help showing in array

This is a discussion on Help showing in array within the C Programming forums, part of the General Programming Boards category; I'm trying to get it so i have two functions. In one function I am declaring each address in the ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    Help showing in array

    I'm trying to get it so i have two functions. In one function I am declaring each address in the array and in the other function I am showing each "grade" that was entered. I want the second part to show the array like so:

    Position_____Grade
    1 (Grade)
    2 (Grade)
    3 (grade)
    etc.

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<ctype.h>
    #include<string.h>
    
    
    #define TRUE 1
    #define FALSE 0
    
    int getgrades(int *grades);
    int menu(void);
    void showgrades(int *grades);
    
    
    main()
    {
          int grades[100];
          
          int key, more = TRUE;
          do
         {
               key = menu();
               switch(key)
               {
                    case 1: getgrades(grades); break;
                    case 2: showgrades(grades); break;
                    case 3: changegrades(); break;
                    case 4: findgrades(); break;
                    case 5: more = quit(); break;
                    default: printf("\nError in selection. Press Enter to Continue\a");
                    getchar();
               }
         }
    while(more);
    return 0;
    }
    
    
    int menu()
    {
         system("cls");
         int selection;
    
         printf("1 = Get Grades\n");
         printf("2 = Show Grades\n");
         printf("3 = Change Grades\n");
         printf("4 = Find Grades\n");
         printf("5 = Quit\n");
    
         /*For user selection*/
         printf("\n\nEnter your selection here: ");
         scanf("%d%*c", &selection);
    
         return(selection);
    }
    
    int getgrades(int *grades)
    {
        int x;
         system("cls");
         printf("Enter Grades\n\n");
    
         do
         {
              printf("Enter Grade or Press 0 to Exit:");
              scanf("%d%*c", grades);
         }
         while(*grades > 0);
    }
    
    
    
    void showgrades(int *grades)
    {
    system("cls");
    int i;
         
         printf("Inputed Grades");
         printf("\n\nPosition_______Grade\n");
         for(i=0; i<20; i++)
         {
         printf("%d%18.0lf\n", i+1, grades);
    }
    getchar();
    }
    
    
    int quit()
    {
    printf("\nPress Enter to Continue");
    getchar();
    return 0;
    }
    Last edited by tdiddy; 04-07-2011 at 07:08 PM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Aside from lacking the standard of int main(void) (for this program), I don't see either a question from you, or understand why you'd want to now change the program so it has only two functions - if you wanted just two functions, you would have designed the program that way in the first place.

    So this isn't your code, but somebody else's.

    Working this problem out will give you some semblance of programming skills, at least. You should do that, because programming skill requires a good deal of practice, I assure you.

    Time for you to get to work, isn't it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning an object with a dynamic pointer
    By maxsthekat in forum C++ Programming
    Replies: 11
    Last Post: 09-16-2009, 01:52 PM
  2. Multidimensional Array Addressing
    By BlackOps in forum C Programming
    Replies: 11
    Last Post: 07-21-2009, 09:26 PM
  3. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  4. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM

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