Results 1 to 16 of 16

Thread: Array Problem....

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Unhappy Array Problem....

    Ok, I'm learning arrays and I pretty much have the concept of them and how they work.. now my problem is that I dont get how to store things in them...

    anyway, I've been working on this problem i'm given and it doesnt look too good:

    PHP Code:
    #include <stdio.h>
    #define GRADES 10

    main()

    {

        
    int Ngrades[GRADES] = {0}, iloop 1;
        
    float totalavg;


        while (
    loop == 1) {
                
    printf("Please enter %d grades\n"GRADES);
            for (
    i=0i<10i++) {
                
    scanf("%d", &Ngrades[i]);
            
                
    printf("Calculating......");
                for (
    i=0i<10i++) {
                    
    total += Ngrades[GRADES];
                }
            
            
    avg = (float) total/(Ngrades[GRADES]);

                
    printf("The %d numbers entered were: \n"GRADES);
                
            for (
    i=0i<10i++) {
                
    printf("Ngrades[%d] = %d\n"iNgrades[i]);
            }

            
    printf("\n");

            
    printf("the avg of the %d numbers was: %.1f\n"GRADESavg);
            
            
            }

                
            }

            return 
    0;


    now.. for some reason, instead of putting the 10 numbers in one array (one demention) it puts each number in a new array....

    what I need it to do is get the 10 grades from ther user, display those 10 numbers, then take the average of all of them...

    then there are other things like calculating the letter grade based on teh average but for now I want to get this straight

    thanks for any help!
    -Emo
    Last edited by Emo; Feb 25th, 2003 at 04:08 PM.
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width