Solidity - Arithmetic Operators

Addition operator (+) works for Numeric as well as Strings. e.g. "a" + 10 will give "a10".


The following code shows how to use arithmetic operators in Solidity.

pragma solidity ^0.5.0;

contract SolidityTest {
   constructor() public{
   function getResult() public view returns(uint){
      uint a = 1; 
      uint b = 2;
      uint result = a + b; //arithmetic operation
      return result; 

Run the above program using steps provided in Solidity First Application chapter.


0: uint256: 3
Kickstart Your Career

Get certified by completing the course

Get Started