// Solidity program to // demonstrate assert // statement pragma solidity ^0.4.18; // Creating a contract contract assertStatement { // Defining a state variable bool result; // Defining a function // to check condition function checkOverflow(uint8 _num1, uint8 _num2) public { uint8 sum = _num1 + _num2; assert(sum<=255); result = true; } // Defining a function to // print result of assert // statement function getResult() public view returns(string memory) { if(result == true) { return "No Overflow"; } else { return "Overflow exist"; } } }
0.4.18