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 (13.2k 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 Jun 2017
  1. Bikram

    3704 Points

  2. Arnab Bhadra

    1502 Points

  3. Hemant Parihar

    1502 Points

  4. Niraj Singh 2

    1481 Points

  5. junaid ahmad

    1432 Points

  6. Debashish Deka

    1384 Points

  7. Rupendra Choudhary

    1220 Points

  8. rahul sharma 5

    1220 Points

  9. Arjun

    1168 Points

  10. srestha

    1010 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 26 - Jul 02
  1. Arjun

    208 Points

  2. akankshadewangan24

    152 Points

  3. Debashish Deka

    138 Points

  4. Hira Thakur

    130 Points

  5. Soumya29

    106 Points


23,399 questions
30,111 answers
67,490 comments
28,426 users