C Language

May 23, 2023

How to use floating arithmetic operator in c language

program to use floating arithmetic operator c language


#include<stdio.h>
int main()
{
    float a=12.4,b=3.8;
    printf("sum=%.2f\n",a+b);
    printf("difference=%.2f\n",a-b);
    printf("product=%.2f\n",a*b);
    printf("a/b=%.2f\n",a/b);
    return 0;
}

output


sum=16.20      
difference=8.60
product=47.12  
a/b=3.26

by : Ajaj Khan

Quick Summary:

First add 12.4 and 3.8 then subtract 12.4 and 3.8 then multiply then divide