Q:

Rust program to create a simple function

belongs to collection: Rust Functions Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Rust program to create a user-defined function to ... >>