This website is for sell contact:- +919827974760 Rust If Else Statement Tutorial with Example
  • Struts
  • JavaScript
  • RubyonRails
  • Java IO
  • Servlet
  • SQL Tutorial
  • JSP
  • Core Java
  • jQuery

  • <

    Rust If Else Statement

    if statement consists of a Boolean expression True or False.If condition is True then if block executed.


    When the condition is false then the else block is executed.

    Nested if-else statement is used to check multiple conditions.

    Rust If Statement Example


    fn main()  
      
     let a=4;  
     if a>1  
      {  
          println!("True");  
       }  
    
    
    

    Output
    
    True
    

    Rust IF Else Example


     fn main()  
    {  
      let a=10;  
      let b=20;  
      if a==b  
      {  
         println!("a is equal to b");  
      }  
      else  
       {  
         println!("a is not equal to b");   
       }  
    }  
    

    Output:
    
    a is not equal to b
    

    capture

    Rust Nested If Else Statement


    fn main() {
       let n =1 ;
       if n > 0 {
          println!("{} is positive",n);
       } else if n < 0 {
          println!("{} is negative",n);
       } else {
          println!("{} is neither positive nor negative",n) ;
       }
    }
    
    

    Output:
    
    1 is positive
    

    capture
















    © copyright 2017-2022 Completedone pvt ltd.