0
#include <iostream>

using namespace std;

int main()
{
	double var1 = 0;

	var1 = 2/10;

	cin.ignore();
	cin.get();

	return 0;
}

Its not setting var1 to .2 it is keeping it at 0. wth?
it does 10/2 = 5, but then it does 2/10 = 0.

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by clutchkiller
0

I know you said it's solved but just to clarify for you. Dividing 2 integers gives an integer result (0) which is then assigned to the double. You found the solution already.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.