Hw help, compiling error.

This is a discussion on Hw help, compiling error. within the C++ Programming forums, part of the General Programming Boards category; #include <iostream> using namespace std; void Outputgrade(double avg); int const SENTINEL = -1; int main() { int i = -1; ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    13

    Hw help, compiling error.

    #include <iostream>
    using namespace std;

    void Outputgrade(double avg);
    int const SENTINEL = -1;
    int main()
    {
    int i = -1;
    double num = 0, sum = 0, avg;
    do
    {
    i++;
    sum += num;
    cout <<" Please enter grades in percent (0-100) or -1 to terminate: ";
    cin >> num;
    while( ((num < 0) || (num >100)) && (num != SENTINEL))
    {
    cout << "you have entered an invalid value please re-enter: ";
    cin >> num;
    }
    }while(num!= SENTINEL);
    avg = (sum/i);

    Outputgrade(double avg);
    return 0;
    }


    void Outputgrade(double avg)
    {
    cout << "The average score for this midterm is :";
    if(avg < 50)
    cout << "F";
    else if (avg <= 60)
    cout << "D";
    else if (avg <= 70)
    cout << "C";
    else if (avg <= 80)
    cout << "B";
    else if (avg <= 95)
    cout << "A";
    else
    cout << "A+";

    }


    Thats my program that calculate the midterm average in term of a,b,c...etc.
    i can't compile because of the following error.
    missing ')' before type double ( at Outputgrade(double avg); )
    and 'Outputgrade' :function does not take 0 parameter.
    anyone could help me?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    First of all, you need to read the sticky post to learn how to use code tags.

    Second, you are calling the Outputgrade function incorrectly. You dont pass a type as a function parameter, just a variable. The correct way to do it would be:

    Code:
    Outputgrade(avg);

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    13
    Quote Originally Posted by bithub
    First of all, you need to read the sticky post to learn how to use code tags.

    Second, you are calling the Outputgrade function incorrectly. You dont pass a type as a function parameter, just a variable. The correct way to do it would be:

    Code:
    Outputgrade(avg);
    SWEET thanks, i'll make sure i'll use the code tag next time,
    i luv u man.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

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