From a62379e27de5d02c198c00ac8bd036284ff7f8d6 Mon Sep 17 00:00:00 2001 From: "[s.hemanth-reddy]" <[hemanthcgg@gmail.com]> Date: Fri, 25 Jan 2019 22:34:45 +0530 Subject: [PATCH 1/6] Added text file --- program.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 program.txt diff --git a/program.txt b/program.txt new file mode 100644 index 0000000..e69de29 From 12c924804e9e50398851f3288d25f597ed983d02 Mon Sep 17 00:00:00 2001 From: "[s.hemanth-reddy]" <[hemanthcgg@gmail.com]> Date: Fri, 25 Jan 2019 23:24:54 +0530 Subject: [PATCH 2/6] remove text file --- program.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 program.txt diff --git a/program.txt b/program.txt deleted file mode 100644 index e69de29..0000000 From 43392b064a1a6bce0d7ea89e1b67d37ac727a295 Mon Sep 17 00:00:00 2001 From: "[s.hemanth-reddy]" <[hemanthcgg@gmail.com]> Date: Fri, 25 Jan 2019 23:33:11 +0530 Subject: [PATCH 3/6] Added text file --- asta.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 asta.txt diff --git a/asta.txt b/asta.txt new file mode 100644 index 0000000..e69de29 From c7f2dc9b177f66ab0a656948683b2149e5aad45b Mon Sep 17 00:00:00 2001 From: hemanth-hemanth <47024424+hemanth-hemanth@users.noreply.github.com> Date: Sat, 26 Jan 2019 04:53:50 +0530 Subject: [PATCH 4/6] infinite loop description --- .../demonstration_of_rust_features/infloop.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/trivial_demonstrations/demonstration_of_rust_features/infloop.rs diff --git a/src/trivial_demonstrations/demonstration_of_rust_features/infloop.rs b/src/trivial_demonstrations/demonstration_of_rust_features/infloop.rs new file mode 100644 index 0000000..dc1cb36 --- /dev/null +++ b/src/trivial_demonstrations/demonstration_of_rust_features/infloop.rs @@ -0,0 +1,11 @@ +fn main(){ + let mut x=0; + + loop{ + x += 5; + if x==100{ + break; + } + println!("the value of x ={}",x); + } +} From dc7a58a169e0d7682e6e650d2f3d7a44ffe759a6 Mon Sep 17 00:00:00 2001 From: hemanth-hemanth <47024424+hemanth-hemanth@users.noreply.github.com> Date: Sat, 26 Jan 2019 05:21:02 +0530 Subject: [PATCH 5/6] sum of digits in number description --- src/sum of digits in number | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/sum of digits in number diff --git a/src/sum of digits in number b/src/sum of digits in number new file mode 100644 index 0000000..c98c2c0 --- /dev/null +++ b/src/sum of digits in number @@ -0,0 +1,14 @@ +fn main(){ + let x = 234; + let a = x%10; + println!("a={}",a); + let aa = x/10; + let s = aa%10; + println!("s={}",s); + let ss = aa/10; + let d = ss%10; + println!("d={}",d); + let f = a+s+d; + println!("the sum is ={}",f); + +} From 3091fd10cc43a5e4d3030dbac93443487ad1a2d3 Mon Sep 17 00:00:00 2001 From: hemanth-hemanth <47024424+hemanth-hemanth@users.noreply.github.com> Date: Sat, 26 Jan 2019 07:00:48 +0530 Subject: [PATCH 6/6] to find roots of quadratic equation description --- src/roots.rc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/roots.rc diff --git a/src/roots.rc b/src/roots.rc new file mode 100644 index 0000000..e364cc5 --- /dev/null +++ b/src/roots.rc @@ -0,0 +1,41 @@ +use std::io; + +/* Prints the roots of a quadratic equation with given coefficients, + * calculated using quadratic formula. + */ + +fn main() { + println!("Quadratic Equation: ax^2 + bx + c = 0"); + + println!("Enter Value of a:"); + let a = read_int(); + + println!("Enter Value of b:"); + let b = read_int(); + + println!("Enter Value of c:"); + let c = read_int(); + + let d = b*b-4*a*c; + if d<0 { + println!("No real roots exist"); + } else { + let root_d = (d as f64).sqrt() as i32; + let r1 = (-b + root_d)/(2*a); + let r2 = (-b - root_d)/(2*a); + + println!("Roots are {} and {}", r1,r2) + } +} + +fn read_int() -> i32 { + let mut num = String::new(); + + io::stdin() + .read_line(&mut num) + .expect("Error Reading Number"); + + num.trim() + .parse::() + .unwrap() +}