-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
142 lines (122 loc) · 2.99 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// fn main() {
// let rect = (50,40);
// println!(
// "the area of the rectangle is {} square pixels.",
// area(rect)
// );
// }
// fn area(dimension:(u32,u32))-> u32 {
// dimension.0*dimension.1
// }
// struct Rectangle{
// width:u32,
// height:u32,
// }
// fn main(){
// let rect1 = Rectangle{width:30,height:50};
// println!("the area of the rectangle is {} square pixel.",
// area(&rect1)
// );
// }
// fn area(rectangle:&Rectangle)->u32{
// rectangle.width*rectangle.height
// }
// #[derive(Debug)]
// struct Rectangle{
// width: u32,
// height: u32,
// }
// impl Rectangle {
// fn area(&self)-> u32{
// self.width * self.height
// }
// }
// fn main(){
// let rect1 = Rectangle{width:50,height:50};
// println!(
// "the area of the rectangle is {} square pixels.",
// rect1.area()
// );
// }
// bounding a variable with a string
// fn main(){
// let x ="Ali Abdullah Raheel Khan Akash";
// let y = {
// let x =5;
// x+4
// };
// println!("the value of the x and y is: {} {}",x,y);
// let z = x.len();
// println!("the length of the variable is:{}",z);
// }
//making a variable mutable and giving another value to that variable
// fn main(){
// let mut x = "ali abdullah raheel khan akash";
// println!("the of the best programmer in this universe is:{}",x);
// x ="ali asadullah shaoor khan akash";
// println!("the name of his younger brother is:{}",x);
// }
// fn main(){l;cin cxxxxxxccckip==
// println!("Hello World");
// another_function();
// }
// fn another_function(){
// println!("another_function");
// }
// fn main(){
// let x = 3;
// if x != 5 {
// println!("the condition was true");
// }
// }
// fn main(){
// let mut counter = 0;
// let result = loop{
// counter +=1;
// if counter==10{
// break counter*2;
// }
// };
// println!("the result of the process is:{}",result);
// }
// fn main(){
// let mut number =3;
// while number !=0{
// println!("{}!",number);
// number -= 1;
// }
// println!("LIFTOFF!!!");
// }
// fn main(){
// let a =[10,20,30,40,50];
// for element in a.iter(){
// println!("the value from a is:{}",element);
// }
//}
// fn main(){
// let s1 = String::from("Hello");
// let len = calculate_length(&s1);
// println!("the length of '{}' is {}.",s1,len);
// }
// fn calculate_length(s: &String)-> usize{
// s.len()
// }
// fn main(){
// let mut s =String::from("Hello,World");
// let _word = first_word(&s);
// println!("the first word of the string is {}",_word);
// s.clear();
// }
// fn first_word(s: &String)-> usize {
// let bytes= s.as_bytes();
// for(i,&item) in bytes.iter().enumerate(){
// if item == b' ' {
// return i;
// }
// }
// s.len()
// }
fn main(){
const PI = 3.14;
println!("{}",PI);
}