Help writing this program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bjeffers
    New Member
    • Oct 2006
    • 2

    Help writing this program

    I need help writing a program that asks the user to enter the number of grades that he/she wants to enter, reads this many number of integer grades (assume each grade is in the range 0..100), and the prints the average of all the grades with 1 decimal point.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by bjeffers
    I need help writing a program that asks the user to enter the number of grades that he/she wants to enter, reads this many number of integer grades (assume each grade is in the range 0..100), and the prints the average of all the grades with 1 decimal point.
    Where is the code that you have tried to write yourself?

    Comment

    • bjeffers
      New Member
      • Oct 2006
      • 2

      #3
      Originally posted by r035198x
      Where is the code that you have tried to write yourself?
      This is what I have so far.
      #include<stdio. h>

      main()
      {

      int integer;
      int integer2;
      int integer3;
      int integer4;

      printf( "Enter number of grades:\n" );
      scanf("%d" , &integer2);

      printf( "Enter grade 1:\n" );
      scanf("%d" , &integer2);

      printf( "Enter grade 2:\n" );
      scanf("%d" , &integer3);

      printf( "Enter grade3:\n" );
      scanf("%d" , &integer4);

      if ( integer2 + integer3 + integer4 /3 );

      printf( "The average of all 3 grades is %d\n" );
      }
      I just can't seem to grasp this stuff.Thanks...

      Comment

      • D_C
        Contributor
        • Jun 2006
        • 293

        #4
        Understanding what an array is would be quite beneficial. Why don't you look at this thread, which talks about arrays. This other person has a similar problem as you do.

        Comment

        Working...