I'm trying to divide by negative numbers where both the quotient and divisor are negative. However it returns 0 when done like this.
#include <iostream>
using namespace std;
int main() {
double m = -46 / -120;
cout << m << endl;
}
output: 0
I'm trying to divide by negative numbers where both the quotient and divisor are negative. However it returns 0 when done like this.
#include <iostream>
using namespace std;
int main() {
double m = -46 / -120;
cout << m << endl;
}
output: 0
As pointed in the comment, it is true that your instance of code will produce 0 even for a Positive number. So it should be like this:
#include<iostream>
int main() {
double m = -46.0 / -120.0;
std::cout << m << '\n';
}