codedamn

If Else

Created by Kshitij about a year ago

0

No description provided

5 Comments

    0

    🔥🔥🔥🔥🔥

    @shashvat23

    shashvat

    @shashvat23

    1

    instead of creating variable 'str' we could have just used keyword 'return' after each condition...

    @chaitanya22

    Chaitanya Patil

    @chaitanya22

    0

    function ss(int m)public pure returns (string memory){ if (m<0){ return "yoo"; } else if (m == 0){ return"hoho"; } else{ return "nonono"; } }

    @chaitanya22

    Chaitanya Patil

    @chaitanya22

    0

    //SPDX-License-Identifier: UNLICENSED

    pragma solidity >=0.5.0 < 0.9.0;

    contract ifelse{

    //note:you cannot use if else conditionals outside a function or globally
    //they must be inside a function  
    
    function check(int num) public pure returns(string memory){
        string memory str;
    
        if(num>0){
            str ="num is grater than zero";
        }
        else if(num==0){
            str = "the number is equals to zero";
        }
        else{
            str ="the number is less than zero";
        }
        return str;
    
    }
    

    }

    @ashish62da5810

    Ashish Prakash

    @ashish62da5810

    0

    Hello everyone Here is a documentation on "require" keyword - https://codedamn.com/news/solidity/what-is-require-in-solidity

Your comment