GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
34 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 (11.1k points)   | 34 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 Feb 2017
  1. Arjun

    5490 Points

  2. Bikram

    4266 Points

  3. Habibkhan

    3972 Points

  4. Aboveallplayer

    3126 Points

  5. Debashish Deka

    2646 Points

  6. sriv_shubham

    2328 Points

  7. Smriti012

    2270 Points

  8. Arnabi

    2114 Points

  9. sh!va

    1780 Points

  10. mcjoshi

    1702 Points

Monthly Topper: Rs. 500 gift card

20,902 questions
26,048 answers
59,771 comments
22,184 users