Hey guys, this is a calculator program.
I keep getting 0s for my answers... is there something wrong with the logic in this function:

main()
    cin >> choice;
    while ( choice != 'q' && choice != 'Q' ) {        
        cout << "For first fraction\n";
        getFract(choice, 1, num1, den1);
        cout << "For second fraction\n";
        getFract(choice, 2, num2, den2);

function

void getFract(char op, int fractNo, int & num, int & den)
{
    cout << "   Enter the numerator: ";
    cin >> num;
    if ( op == '/' && fractNo == 2 && num == 0 ) {
        cout << "\nTo divide, the second fraction must be nonzero\n";
        while ( num == 0 ) {
            cout << "\nEnter a nonzero number for the numerator: ";
            cin >> num;
        } // endwhile
    } // endif

    cout << " Enter the denominator: ";
    cin >> den;
    if ( den = 0 ) {
        cout << "The denominator must be nonzero\n";
        while ( den = 0 ) {
            cout << "\nEnter the denominator: ";
            cin >> den;
        } // endwhile
    } // endif
}

>if ( den = 0 ) {
>while ( den = 0 ) {
= is assignment, == is comparison.

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.