GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
36 views

just confused in these things-

we are perfoming a/b

if we have two INT variables a=6 and b=2

in which scenario we will get answe as 

  • 3
  • 3.0

similarly ,if they are float then when will we get 

  • 3
  • 3.0

if we have two floats as a=3.2 and b= 1.1

then what will be the answer on division

asked in Programming by Veteran (13.2k points)   | 36 views

for integer variables it prints as 3 only not 3.0

for foat variables it prints as 3.000000 

if we declare like  printf("%.2f",a);  // upto 2 decimal places.

foat a=3.2

float b=1.1

float c=3.2/1.1

printf("%.2f",c);   // o/p as 2.90

in case of float,it wont print 3 anyhow??

Please log in or register to answer this question.



Top Users Aug 2017
  1. ABKUNDAN

    4658 Points

  2. Bikram

    4032 Points

  3. akash.dinkar12

    3136 Points

  4. rahul sharma 5

    2856 Points

  5. manu00x

    2664 Points

  6. makhdoom ghaya

    2380 Points

  7. just_bhavana

    2040 Points

  8. Tesla!

    1756 Points

  9. pawan kumarln

    1574 Points

  10. learner_geek

    1558 Points


24,879 questions
31,953 answers
74,105 comments
30,065 users