Thread: Finding an Average

  1. #1
    Back after five years?
    Join Date
    Feb 2002
    Posts
    19

    Question Finding an Average

    I am trying to write a program so a teacher or parent can find out overall how well a child is doing in school. I am not sure how to end it-----I am not even sure if I got it right so far, but here it goes:

    #include <iostream.h>
    int main ( )
    {
    cout<<“Thanks for using Kidguru’ s Cool Game !”;
    return 0;
    }
    int find
    {
    cout<<“Please Enter Reading-Writing Grade 1-100:”;
    cin>> find
    cout<<“Pleas Enter Science Grade 1-100:”;
    cin>> find
    cout<<“Please Enter Social Studies Grade 1-100:”;
    cin>> find
    cout<<“Please Enter Mathematics Grade 1-100:”;
    cin>>find
    cout<<Your Average Is:

    And that is where I don't know! HELP! (I would also like to know how to figure out if codes are compatibe with which certain OSs?
    BMSprint.com - Waste your time reading my drivel about politics and life.
    Please, sometimes there's just nothing else better to do.
    Oh yeah, and pretty soon I am going to host a TV Show on BMSprint.com too. Another time waster.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Read each grade into an integer, then to calculate the average add the grades together and divide the result by the number of grades.
    cout<<"Average is "<< ( read + sci + soc + math ) / 4 <<endl;

    >how to figure out if codes are compatibe with which certain OSs
    Codes? If you mean C code then there is a standard for which the supported functions and constructs will work everywhere. The best way to find out is to order a copy of the ISO C standard from www.ansi.org or take a look at www.rt.com/man and at the bottom of each function description it will tell you if the function is ISO standard.

    -Prelude
    Last edited by Prelude; 02-23-2002 at 07:24 PM.
    My best code is written with the delete key.

  3. #3
    Back after five years?
    Join Date
    Feb 2002
    Posts
    19

    Question You mean like This?

    You mean like this?:

    #include <iostream.h>
    int main( )
    {
    Kidguru's GradeFinder! 1 ";
    }
    int read
    {
    cout<<"Please enter Reading and Writing Grade 1-100":;
    cin>>read
    }
    int sci
    {
    cout<<"Please enter Science Grade 1-100":;
    cin>>sci
    }
    int soc
    {
    cout<<"Please enter Social Studies Grade 1-100":;
    cin>>soc
    }
    int math
    {
    cout<<"Please enter Mathematics Grade 1-100":;
    cin>>math
    }
    int total
    {
    cout<<"And the Average is:"<< ( read + sci + soc + math ) / <<endl;
    BMSprint.com - Waste your time reading my drivel about politics and life.
    Please, sometimes there's just nothing else better to do.
    Oh yeah, and pretty soon I am going to host a TV Show on BMSprint.com too. Another time waster.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Something along those lines, yes. Also, in the future if you have a C++ question be sure to ask it in the C++ forum, you may get more replies

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    The fact that you only have one find variable, which will subsequently be overwritten must be sorted. Use an array or several discrete variables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help in finding average of a class of numbers
    By hastefan2001 in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2009, 01:11 PM
  2. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  4. Replies: 9
    Last Post: 11-20-2003, 08:55 PM
  5. Finding Average of floats
    By sonict in forum C++ Programming
    Replies: 8
    Last Post: 12-01-2002, 08:52 PM