ask Using two integers num1 and mun2
divide the first by the second
print out guotient and remainder both ints

output looks like this

First number entered
second number entered

Quotient
Remainder

Recommended Answers

All 4 Replies

The program is having many mistakes, firstly you are dividing the two numbers and then assigning them the values . So when the program encounters the statement of quotient , it will do something like 0/0. which is an error.similarly for remainder. also you are not printing the outputs . a statement like cout<<"quotient: " will print whatever is wriiten in quotes. removing quotes shall give the answer.
cout<<quotient;

if a and b are integers.....

quotient = a / b;
remainder = a % b;

Here's how its supposed to handle. Check it out and hope it helps

#include <iostream>
using namespace std;

int main()
{
    int num1=0;
    int num2=0;
    int quotient=0;
    int remainder=0;    

    cout << "first number entered:  ";
    cin >> num1;
    cout << "second number entered: ";
    cin >> num2;

    if (num2==0)
    {
        cout << num2 << " Cannot divide by Zero\n";
    } else
    {
        quotient  = num1 / num2;
        remainder = num1 % num2;
    
        cout << "Quotient:  " << quotient  << endl;
        cout << "Remainder: " << remainder << endl;

        //system("pause"); // you really need this??
    }
    return 0;
}

thanks for all your help . Everything work great now.

Be a part of the DaniWeb community

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