How to use floating point arithmetic operators in C language

Program to use floating point arithmetic operators in 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("Proudct=%.2f\n", a * b);
    printf("a/b=%.2f\n", a / b);
    return 0;
}

Output


Sum=16.20
Difference=8.60
Proudct=47.12
a/b=3.26

Steps / Description

  1. Declare variable float a and b
  2. Initialize in float variable a = 10.4, b = 5.8
  3. printf inbuild function to display sum of variable a > and b with decimal place holder %f
  4. prinf inbuild function to display difference of variable a and b with decimal place holder %f
  5. printf inbuild function to display product of variable a and b with decimal place holder %f
  6. printf inbuild function to display a/ba and b with decimal place holder%f

How to use arithmetic operators in c language

program to use arithmetic operators in c language


#include<stdio.h>
int main()
{
    int a=12,b=6,res;
    res=a + b;
    printf("sum : %d\n", res);
    res=a-b;
    printf("difference : %d\n", res);
    res=a*b;
    printf("product : %d\n", res);
    res=a/b;
    printf("quotient : %d\n", res);
    res=a%b;
    printf("remainder : %d\n", res);
    return 0;
}

output


sum : 18
difference : 6
product : 72
quotient : 2
remainder : 0

Steps Description

  1. Declare integer three variable a,b and res
  2. Initialize in integer variable a=12, b=6
  3. Assign res variable with sum of variable a and b
  4. printf inbuild function display res variable with decimal placeholder %d
  5. Assign res variable with difference of variable a and b
  6. printf inbuild function display res variable with decimal placeholder %d
  7. Assign res variable with product of variable a and b
  8. printf inbuild function display res variable with decimal placeholder %d
  9. Assign res variable with quotient of variable a and b
  10. printf inbuild function display res variable with decimal placeholder %d
  11. Assign res variable with remainder of variable a and b
  12. printf inbuild function display res variable with decimal placeholder %d

How to use Arithmetic operators in C Language

  • Program to use Arithmetic operators in C Language

    
    #include <stdio.h>
    int main()
    {
        int a = 17, b = 4;
        printf("sum=%d\n", a + b);
        printf("defference=%d\n", a - b);
        printf("proudct=%d\n", a * b);
        printf("quotient=%d\n", a / b);
        printf("remainder=%d\n", a % b);
        return 0;
    }
    

    output

    
    sum=21
    difference=13
    product=68
    quotient=4
    remainder=1
    

    Step / Description

    1. Declare integer variable a and b
    2. Initialize int integer variable a = 17, b = 4
    3. printf inbuild function to display sum of variable a and b with decimal place holder %d
    4. printf inbuild function to display difference of variable a and b with decimal place holder%d
    5. printf inbuild function to display product of variable a and b with decimal place holder %d
    6. printf inbuild function to display quotient of variable a and b with place holder %d
    7. printf inbuild function to display remainder of variable a and b with decimal place holder %d
  • How to use Arithmetic Operators JavaScript Language

    Program to use ( + ) Addition Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a + b;
    console.log('c = ', c);
    

    Output

    
    c = 8
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the sum/Addition value of variables a and b
    4. a, b variables की value को (+) Addition Operators ki सहयता से a+b numbers को sum/Addition किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( - ) Subtraction Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a - b;
    console.log('c = ', c);
    

    Output

    
    c = 2
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the subtraction/minus value of variables a and b
    4. a, b variables की value को (-) Subtraction Operators ki सहयता से a-b numbers को subtraction/minus किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( * ) Multiplication Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a * b;
    console.log('c = ', c);
    

    Output

    
    c = 15
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the multiplie/गुड़ा value of variables a and b
    4. a, b variables की value को (*) Multiplication Operators ki सहयता से a*b numbers को multiplie/गुड़ा किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( / )Division Operator JavaScript Language

    
    let a = 15;
    let b = 3;
    let c;
    c = a / b;
    console.log('c = ', c);
    

    Output

    
    c = 5
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 15 and 3 respectively a=15, b=3
    3. Assign c variable with Assignment Operators (=) with the divides/भाग value of variables a and b
    4. a, b variables की value को (/) Division Operators ki सहयता से a/b numbers को divides/भाग किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( % ) Modulus/Remainder Operator JavaScript Language

    
    let a = 10;
    let b = 3;
    let c;
    c = a % b;
    console.log('c = ', c);
    

    Output

    
    c = 1
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 10 and 3 respectively a=10, b=3
    3. Assign c variable with Assignment Operators (=) with the modulus/remainder value of variables a and b
    4. a, b variables की value को (%) Modulus/Remainder Operators ki सहयता से a%b numbers को modulus/remainder किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( ++ ) Increment Operators JavaScript Language

    
    let b = 3;
    console.log('b = ',b)
    console.log('++b = ',++b)
    console.log('b++ = ',b++)
    

    Output

    
    b = 3 , ++b = 4 , b++ = 4
    

    Steps Description

    1. Declare variable b
    2. Initialize variable with value of 3 respectively b=3
    3. console.log inbuilt function की मदद्द से b variable की value को display किया गया हैं
    4. console.log inbuilt function की मदद्द से (++) Increment Operators की सहयता से (++b) prefix Increment numbers किया और b variable की value को display किया गया हैं
    5. console.log inbuilt function की मदद्द से (++) Increment Operators ki सहयता से (b++) postfix Increment numbers किया और b variable की value को display किया गया हैं

    Program to use ( -- ) Decrement Operators JavaScript Language

    
    let a = 5;
    console.log('a = ',a)
    console.log('--a = ',--a)
    console.log('a-- = ',a--)
    

    Output

    
    a =  5 , --a = 4 , a-- = 4
    

    Steps Description

    1. Declare variable a
    2. Initialize variable with value of 5 respectively a=5
    3. console.log inbuilt function की मदद्द से a variable की value को display किया गया हैं
    4. console.log inbuilt function की मदद्द से (--) Decrement Operators की सहयता से (--a) prefix Decrement numbers किया और a variable की value को display किया गया हैं
    5. console.log inbuilt function की मदद्द से (--) Decrement Operators ki सहयता से (a--) postfix Decrement numbers किया और a variable की value को display किया गया हैं

    Program to use ( ** ) Exponentiation Operators JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a ** b;
    console.log('c = ', c);
    

    Output

    
    c = 125
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the Exponentiation value of variables a and b
    4. a, b variables की value को (**) Exponentiation Operators ki सहयता से a*b numbers को Exponentiation (5**3 / 5*5*5 = 125) किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं