Industrial Training




First Rust program

Let's write the simple program in Rust language. Now, open the notepad file and write the following code:


fn main()  
  
    println!("Hello, world!");  

Output:
Hello, world!

main(): The main() function is always the first code in every Rust executable code. The main() function is enclosed in curly braces{}. The main() function does not contain any parameter as well as it does not return any value.
println!: It is a Rust macro. If it calls the function, then it does not contain '!'.
"Hello World": It is a string passed as a parameter to the println!, and the string is printed to the console.


Procedure to create, compile and run the program


1. Open the notepad file and write the code in a notepad file.
2. Save the file with .rs extension.



3. Open the command prompt
4. Set the path of the directory. Suppose the project is located in D drive.



5. Compile the above program using the rustc command.



6. Finally, run the program by using the command filename.exe.





Hi I am Pluto.