Math_module/
lib.rs

1
2use std::io;
3// pub fn sum(){
4//         let mut a = String::new();
5//         println!("Enter number of i32 type");
6//         io::stdin().read_line(&mut a);
7//         let mut b = String::new();
8//         println!("Enter number of i32 type");
9//         io::stdin().read_line(&mut b);
10//         let _type1 : i32 =a.trim().parse().unwrap();
11//         let _type2 : i32 =b.trim().parse().unwrap();
12//         let total : i32 =_type1 as i32  +_type2 as i32 ;
13//         println!("{}", total)
14           
15// }
16fn sum(){
17    let mut a = String::new();
18    println!("How many number you want to add");
19    io::stdin().read_line(&mut a);
20    let _type1 : i32 =a.trim().parse().unwrap();
21    let mut v: Vec<i32> = Vec::new();
22    for i in 0.._type1{
23        let mut a = String::new();
24        println!("Enter your numnber");
25        io::stdin().read_line(&mut a);
26        let _type2 : i32 =a.trim().parse().unwrap();
27        v.push(_type2);
28    }
29    println!("{:?}",v );
30    let mut init : i32 =0;
31    for mut i in &mut v{
32        init+=*i;
33        println!("{}",init);
34    }
35
36}
37pub fn difference(){
38        let mut a = String::new();
39        println!("Enter number of i32 type");
40        io::stdin().read_line(&mut a);
41        let mut b = String::new();
42        println!("Enter number of i32 type");
43        io::stdin().read_line(&mut b);
44        let _type1 : i32 =a.trim().parse().unwrap();
45        let _type2 : i32 =b.trim().parse().unwrap();
46        let total : i32 =_type1 as i32  - _type2 as i32 ;
47        println!("{}", total)
48           
49}
50pub fn devision(){
51        let mut a = String::new();
52        println!("Enter number of i32 type");
53        io::stdin().read_line(&mut a);
54        let mut b = String::new();
55        println!("Enter number of i32 type");
56        io::stdin().read_line(&mut b);
57        let _type1 : f32 =a.trim().parse().unwrap();
58        let _type2 : f32 =b.trim().parse().unwrap();
59        let total =(_type1 /_type2 ) as f32  ;
60        println!("{}", total)
61           
62}
63pub fn multiplication(){
64        let mut a = String::new();
65        println!("Enter number of i32 type");
66        io::stdin().read_line(&mut a);
67        let mut b = String::new();
68        println!("Enter number of i32 type");
69        io::stdin().read_line(&mut b);
70        let _type1 : i32 =a.trim().parse().unwrap();
71        let _type2 : i32 =b.trim().parse().unwrap();
72        let total =_type1 *_type2   ;
73        println!("{}", total)
74           
75}