ADVERTISEMENT
ADVERTISEMENT

Rust program to create a simple function

Rust | Function Example: Write an example to create a simple function. Here, we will write a function to print "Hello World".
Submitted by Nidhi, on October 06, 2021

Problem Solution:

In this program, we will create a user-defined function SayHello() to print the "Hello World" message.

Program/Source Code:

The source code to create a simple function is given below. The given program is compiled and executed successfully.

// Rust program to create a 
// simple function

fn SayHello(){
    println!("Hello World");
}

fn main() {
    SayHello();
}

Output:

Hello World

Explanation:

In the above program, we created two functions SayHello() and main(). The SayHello() function is a user-defined function to print the "Hello World" message.

In the main() function, we called SayHello() function and printed the "Hello World" message.

Rust Functions 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.