Thread: homework help Please!

  1. #1
    Registered User
    Join Date
    Mar 2013

    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.

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

  2. #2
    Registered User
    Join Date
    May 2009
    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!
    int num = 999;
    Tim S.
    Last edited by stahta01; 03-10-2013 at 04:20 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jun 2005
    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%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

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, 08:06 PM
  2. Help for Homework!
    By alionas in forum C Programming
    Replies: 4
    Last Post: 11-20-2010, 10: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