homework help Please!

This is a discussion on homework help Please! within the C Programming forums, part of the General Programming Boards category; Write a program that a prof can use to enter the test marks of several students and which calculates the ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    31

    homework help Please!

    1. Write a program that a prof can use to enter the test marks of several students and which calculates the average mark of each student. Ask the user how many students he has, then ask him to enter each student's marks. When 999 is entered, calculate the average mark for that student (not counting the 999) and print the average. Then go on to the next students until the marks for all students have been entered, calculated and the average printed.


    Code:
     
    Code:
    #include<stdio.h>
    main()
    {
                float student,mark,total=0;
                float a,b,c;
                int num = 999;
                printf("\nPlease enter how many students you have: " );
                scanf("%f",&student);
                do {
                printf("\nPlease enter each student's marks: ");
                scanf("%f",&mark);
                total = total + mark;
                } while(mark!=num);
                a = total - 999;
                b = a / (student*100);
                c = b * 100;
                printf("\nThe average is %.2f%%.",c);
                getch();
    }
    Could you please give some suggestion about this program?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,553
    Use meaningful variable names.
    Indent the code so it is easy to follow.

    This should be a constant and better named; and the use it instead of 999!
    Code:
    int num = 999;
    Tim S.
    Last edited by stahta01; 03-10-2013 at 04:20 PM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,266
    You might try actually reading the homework question more closely - it gives several clues about what you need to do, which you quite clearly have not acted on.

    More generally, read this link.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please help me with my c++ homework!
    By dmeyers81 in forum C++ Programming
    Replies: 4
    Last Post: 11-30-2010, 07:06 PM
  2. Help for Homework!
    By alionas in forum C Programming
    Replies: 4
    Last Post: 11-20-2010, 09:36 AM
  3. Please help me with my c++ homework!
    By dmeyers81 in forum C++ Programming
    Replies: 35
    Last Post: 11-04-2010, 07:47 AM
  4. Homework
    By cagurtay in forum C Programming
    Replies: 3
    Last Post: 11-01-2010, 05:28 PM

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