I have to create a small program which takes world population and a nations population as long long int. Then I have to divide and figure out the percentage of population but when I try to cast it it does not seem to work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
longlong world, nation;
cout << "enter world population: ";
cin >> world;
cout<< "enter nation population: ";
cin >> nation;
p = (static_cast<double> (nation)/static_cast<double> (world))*100;
cout << "the population of the US is " << p << " of the world population.";
Never mind figured it out. I was casting it after the calculation was done in int which would lose all decimal values.