I'm getting errors on lines 8 & 43. I can't figure out what I'm doing wrong here (besides beating my head against the desk.)

#include <iostream>
using namespace std;

{
 try
    {
    if (num1 < 0) throw low;
    if (num2 < 0) throw low;
    if (num3 < 0) throw low;
    if (num4 < 0) throw low;
    if (num1 > 100) throw high;
    if (num2 > 100) throw high;
    if (num3 > 100) throw high;
    if (num4 > 100) throw high;

    catch (...)
    {
    cout << "Number out of range." << endl;
    }
}



int main()
{

int num1, num2, num3, num4;
int avg;

cout << "Enter four numbers to be averaged." << endl;
cout << "\nNumbers must be between 0 and 100." << endl;


    avg = (num1 + num2 + num3 + num4)/4;
    cout << "The average is: " << avg << endl;
    }


 return 0;
}

Either make try block inside main...or call a function from main which contains you try block...what are low, high...u haven't declared them anywhere...where are u asking for values of num1, num2...try reading the book again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.