Hi I would like to know if there is any way to obtain a float result from a division between two integers other than using "from __future__ import division"?

I am not looking for the .0 'trick'. Example 4/5.0 = 0.8.

I want to be able to do 4/5 = 0.8.

Thanks.

Hi, can you help me:

Which of the following options is a correct C++ instruction to calculate the number of containers filled with milk
that can be sold?
1. nrContainers = totalLitres - litresLeftOver;
2. nrContainers /= 5;
3. nrContainers = totalLitres / 5;
4. nrContainers = totalLitres % 5;
5. nrContainers = litresLeftOver * 5;

Question 2
Which of the following options is a correct C++ instruction to calculate the number of litres that will be left over?
1. litresLeftOver = totalLitres - nrContainers;
2. litresLeftOver /= 5;
3. litresLeftOver = totalLitres / 5;
4. litresLeftOver = totalLitres % 5;
5. litresLeftOver = nrContainers * 5;

Recommended Answers

All 4 Replies

what do you think?

Hijacking threads is not looked upon kindly - start your own for a new topic.

Read the announcements - we won't do your homework for you. If you tell us which answer you think is correct, and explain your reasoning, we'll be more inclined to help.

u can divide 2 nos n can obtain a floating result
consider dis eg:
int a,b;
float avg;
avg=(float)(a+b)/2;
dis will result in floating pt result in case u r using 2 integer nos 4 division . dis concept is known as type casting..

commented: Talk in normal English! -4
Be a part of the DaniWeb community

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