GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
35 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 (12.6k points)   | 35 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 Mar 2017
  1. rude

    5236 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2732 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1402 Points

  9. Bikram

    1384 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,545 questions
26,881 answers
61,232 comments
23,243 users