Saturday, January 7, 2023

Subtract Two Numbers in Rust

 A simple program that I wrote using Rust programming language that will ask the user to give two numbers and then the program will subtract the difference of the two given numbers and display the results on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


You can buy my C++ book online at  


https://www.mindshaperspublishing.com/product/beginners-guide-to-c-programming/


You can buy my book in introduction to computer networking at 

https://www.unlimitedbooksph.com/product-page/introduction-to-computer-networking


Want to support my channel?

GCash Account

Jake Pomperada


09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.






Program Listing

/* diff.rs Author : Mr. Jake Rodriguez Pomperada, MAED-IT, MIT Date : January 6, 2023 Friday 9:46 PM Address : #25-31 Victoria Malaga Street Eroreco Subdivision 6100 Bacolod City, Negros Occidental Philippines Websites : www.jakerpomperada.com and www.jakerpomperada.blogspot.com Facebook : https://www.facebook.com/jakerpomperada YouTube Channel : http://www.youtube.com/jakepomperada Email : jakerpomperada@gmail.com Mobile Number : 09173084360 Telephone Number : (034) 433-5675 */ use std::io; use std::{i32}; fn main() { println!("\n"); println!("Subtract Two Numbers in Rust\n\n"); // User will give the first value. println!("Give First Value : "); let mut var1 = String::new(); io::stdin().read_line(&mut var1).expect("Unable to read entered data"); println!("\n"); // User will give the second value. println!("Give Second Value : "); let mut var2 = String::new(); io::stdin().read_line(&mut var2).expect("Unable to read entered data"); // Converting string to integer let a: i32 = var1.trim().parse().ok().expect("Program only processes numbers, Enter number"); let b: i32 = var2.trim().parse().ok().expect("Program only processes numbers, Enter number"); // Performing subtraction of two values variable a and variable b let subtract = a-b; // Output of basic operations println!("\n"); println!("The difference between {} and {} is {}.",a,b, subtract); println!("\n"); println!("End of Program"); println!("\n"); } // End of Code

No comments:

Post a Comment