ADVERTISEMENT
ADVERTISEMENT

Rust program to demonstrate the logical AND operator

Here, we are going to demonstrate the logical AND 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 find the largest number among them using the logical AND operator and print the appropriate message.

Program/Source Code:

The source code to demonstrate the logical AND operator is given below. The given program is compiled and executed successfully.

// Rust program to demonstrate 
// the logical AND operator

fn main() {
    let mut num1:i32=22;
    let mut num2:i32=15;
    let mut num3:i32=16;
    
    if(num1 > num2 && num1 > num3)
    {
        println!("Num1 is largest number");
    }
    else if(num2 > num1 && num2 > num3)
    {
        println!("Num2 is largest number");
    }
    else
    {
        println!("Num3 is largest number");
    }
}

Output:

Num1 is largest number

Explanation:

Here, we created three integer variables num1, num2, num3 that are initialized with 22, 15, 16 respectively. Then we found the largest number among them and printed the appropriate message.

Rust Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.