In c when i try to divide two numbers in which denominator is multiplied by 1000 is often displaying me the output as 0?Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In c when i try to divide two numbers in which denominator is multiplied by 1000 is often displaying me the output as 0?Why?

6th Dec 2016, 8:09 AM
PRAVALLIKA.K
PRAVALLIKA.K - avatar
6 Answers
+ 3
you have to declare numbers in float type
18th Dec 2016, 3:59 PM
H.M. Ravindu T. Bandara
H.M. Ravindu T.  Bandara - avatar
+ 1
yes... as c by default consider all value as integer... so if your denominator > nenominator then the value will be 0...
6th Dec 2016, 8:27 AM
Amit
Amit - avatar
+ 1
then how to solve this problem@ Amit H TO O
6th Dec 2016, 8:31 AM
PRAVALLIKA.K
PRAVALLIKA.K - avatar
+ 1
declare two variable using float or double data type and assign nenominator and denominator... then devide..
6th Dec 2016, 8:36 AM
Amit
Amit - avatar
+ 1
or you can write like this float c; c=a/1000; where a is any number
6th Dec 2016, 8:37 AM
Amit
Amit - avatar
+ 1
Tq very much @Amit H TO O .I got the correct answer
6th Dec 2016, 8:40 AM
PRAVALLIKA.K
PRAVALLIKA.K - avatar