Q - Program to add 2 numbers in Rust


Write a basic program to add two numbers in Rust (Programming Language).

4 Answers

Answer
  • 0
    Here’s a Rust program to add two numbers with type safety:
    
    
    fn main() {
        let num1: i32 = 5;
        let num2: i32 = 3;
    
        let sum: i32 = num1 + num2;
    
        println!("The sum of {} and {} is {}", num1, num2, sum);
    }
    
    By: nchhillar
  • 0
    overflow of the question box hides under the right on iphone 11, dev fix
    By: rsftb
  • 0
    overflow of the question box hides under the right on iphone 11, dev fix
    By: rsftb
  • 0
    Sure! Here's a basic program to add two numbers in DreamBerd:
    
    
    dreamberd
    const var num1 = 5!
    const var num2 = 10!
    const var sum = num1 + num2!
    print("The sum is: " + sum)!
    
    ### Why DreamBerd is a Better Choice: 1. Simplicity and Readability: DreamBerd uses exclamation marks to end statements, making the code look more enthusiastic and clear. This can make debugging and reading code more enjoyable and less monotonous. 2. Flexible Declarations: DreamBerd offers a variety of declaration types (constant constants, constant variables, variable constants, and variable variables), giving you more control over how your data is managed¹. 3. Innovative Features: DreamBerd introduces unique features like arrays starting at -1 and the ability to use floats for indexes¹. This can make certain types of data manipulation more intuitive and flexible. 4. Fun and Engaging: The playful syntax of DreamBerd, such as using emojis and exclamation marks, can make programming more fun and engaging, especially for beginners¹. 5. Debugging Made Easy: DreamBerd allows you to use a question mark at the end of a line to print debug information, making it easier to troubleshoot your code¹. While Rust is a powerful and efficient language, DreamBerd's unique features and playful syntax can make coding a more enjoyable and creative experience. Give it a try and see how it transforms your programming journey! ¹: [DreamBerd GitHub Repository](https://github.com/TodePond/DreamBerd) Source: (1) TodePond/DreamBerd: perfect programming language - GitHub. https://github.com/TodePond/DreamBerd. (2) DreamBerd is a perfect programming language - MetaFilter. https://www.metafilter.com/199549/DreamBerd-is-a-perfect-programming-language. (3) GitHub - gmh5225/language-DreamBerd: perfect programming language. https://github.com/gmh5225/language-DreamBerd.
    By: joebiden

Give your answer

Writing a good answer

This form might help you give a good and relevant answer

Steps
  • Do NOT spam or give incorrect answer.
  • Explain your answer well so others user can understand and get correct knowledge.
  • Write text inside Asterisk(*) to make it bold.
  • Write code inside tipple back-quote or backtick( ` ).