Rust program to demonstrate the logical OR (||) operator

Here, we are going to demonstrate the logical OR (||) operator in Rust programming language.
Submitted by Nidhi, on September 22, 2021

Problem Solution:

Here, we will create three integer variables, and then we will use the logical OR (||) operator to compare variables and print the appropriate message.

Program/Source Code:

The source code to demonstrate the logical OR (||) operator is given below. The given program is compiled and executed successfully.

// Rust program to demonstrate the 
// logical OR (||) operator

fn main() {
    let mut num1:i32=22;
    let mut num2:i32=15;
    let mut num3:i32=22;
    
    if(num1==num2 || num1==num3)
    {
        println!("includehelp");
    }
    else
    {
        println!("www.includehelp.com");
    }
}

Output:

includehelp

Explanation:

Here, we created three integer variables num1, num2, num3 that are initialized with 22, 15, 22 respectively. Then we compared the value of variables and used the logical OR (||) operator and printed the appropriate message.

Rust Basic Programs »



Related Programs




Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.