Wednesday, December 12, 2012 #

floating point arithmetic

Floating point arithmetic
      When both the operands are of float type then the arithmetic   operation with these operands is called Floating point arithmetic.
Ex- Let us take two variables a and b . The values a=12.4 and b=3.1 . The result of these operation are as –
Expression         result
a+b                       15.5
a-b                         9.3
a*b                        38.44
a/b                          4.0
 The modulus operator % can not beused with floating point numbers.
/* program to understand  the floating point arithmetic operation*/
#include <stdio.h>
Void main( )
Float a=9.6,b=1.6;
Printf(“ after addition :%f\n”,a+b);

Printf(“after subtraction :%f\n’,a-b);

Printf(“after division:%f\n”a/b);

Printf(“after multiplication :%f\n”a*b)

After addition : 11.2
After subtraction:8.0
After division: 6.0
After multiplication: 15.36

posted @ Wednesday, December 12, 2012 4:19 PM | Feedback (0)

Copyright © Afsana Bano

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski