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

Francis Waldron
0
Newbie Poster

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

```
/********************************************************
* Name: template
* Author: Francis Waldron
* Date due: 25/09/06
* Description: basic C++ programming
**********************************************************/
/***************************
* libraries
****************************/
#include <iostream> // needed for Cin and Cout
using namespace std;
/************************************
* defines
*************************************/
#define PI 3.14159
/*************************************
* function prototype
*************************************/
/************************************
* global variables
*************************************/
int main()
{
float num1 = 0;
float num2 = 0;
int quotient = 0;
int remainder = 0;
quotient = num1 / num2;
remainder = num1 % num2;
cout << " first number entered: ";
cin >>num1;
cout << " second number entered: ";
cin >>num2;
if(num2 == 0)
{
cout << num2<< " Cannot divide by Zero";
}
cout << "Quotient: /n";
cout << "Remainder: /n";
system("pause");
return 0;
}
```

Jump to PostThe 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 . …

rati
0
Junior Poster in Training

cout<<quotient;

TylerSBreton
13
Junior Poster in Training

if a and b are integers.....

quotient = a / b;

remainder = a % b;

may4life
2
Junior Poster in Training

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;
}
```

Francis Waldron
0
Newbie Poster

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.