Skip to main content

Command Palette

Search for a command to run...

Dart Operators : Arithmetic

Updated
2 min read
Dart Operators : Arithmetic
V

"Hello World, I'm Vinit Mepani, a coding virtuoso driven by passion, fueled by curiosity, and always poised to conquer challenges. Picture me as a digital explorer, navigating through the vast realms of code, forever in pursuit of innovation.

In the enchanting kingdom of algorithms and syntax, I wield my keyboard as a magical wand, casting spells of logic and crafting solutions to digital enigmas. With each line of code, I embark on an odyssey of learning, embracing the ever-evolving landscape of technology.

Eager to decode the secrets of the programming universe, I see challenges not as obstacles but as thrilling quests, opportunities to push boundaries and uncover new dimensions in the realm of possibilities.

In this symphony of zeros and ones, I am Vinit Mepani, a coder by passion, an adventurer in the digital wilderness, and a seeker of knowledge in the enchanting world of code. Join me on this quest, and let's create digital wonders together!"

Arithmetic operators :

  • Like all programming language dart also support arithmetic operators.

  • Arithmetic operators means simple math function we can use in dart as well like Addition , Subtract and other mathematical function.

  • Here , Below I have mention all Arithmetic operators with simple definition and Example as well.

  • | Operator Symbol | Operator Name | Operator Description | | --- | --- | --- | | + | Addition | Use to add two operands | | – | Subtraction | Use to subtract two operands | | -expr | Unary Minus | It is Use to reverse the sign of the expression | | * | Multiply | Use to multiply two operands | | / | Division | Use to divide two operands | | ~/ | Division | Use two divide two operands but give output in integer |

void main() {
    var x = 5;
    var y = 2;

    var addition = x + y;
    var subtraction = x - y;
    var multiplication = x * y;
    var division = x / y;
    var division_1 = x / y;
    var modulus = x % y;

    print('x + y = $addition'); 
    print('x - y = $subtraction');
    print('x * y = $multiplication');
    print('x / y = $division');
    print('x ~/ y = $division_1');
    print('x % y = $modulus');
    print('x++ = ${++x}');
    print('y-- = ${--y}');
}

/** Output:- 

x + y = 7
x - y = 3
x * y = 10
x / y = 2.5
x ~/ y = 2.5
x % y = 1
x++ = 6
y-- = 1
**/

More from this blog

Vinit Mepani (Flutter Developer)

270 posts

"Vinit Mepani, passionate coder! Dive into my Dart and Flutter journey on the blog. Let's master these tech wonders together. Happy coding! 🚀"