File tree 3 files changed +48
-14
lines changed
3 files changed +48
-14
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ using namespace std ;
4
+
5
+ float mysquare (float value)
6
+ {
7
+ float result = 0 .0f ;
8
+
9
+ if (value >= 1 .0f || value <= 0 )
10
+ {
11
+ cerr << " The input is out of range." << endl;
12
+ goto EXIT_ERROR;
13
+ }
14
+ result = value * value;
15
+ return result;
16
+
17
+ EXIT_ERROR:
18
+ // do sth such as closing files here
19
+ return 0 .0f ;
20
+ }
21
+
22
+ int main ()
23
+ {
24
+ float value;
25
+ cout << " Input a floating-point number." << endl;
26
+ cin >> value;
27
+
28
+ float result = mysquare (value);
29
+
30
+ if (result > 0 )
31
+ cout << " The square is " << result << " ." << endl;
32
+
33
+ return 0 ;
34
+ }
Original file line number Diff line number Diff line change @@ -9,20 +9,20 @@ int main()
9
9
num--;
10
10
}
11
11
12
- num = 10 ;
13
- do
14
- {
15
- cout << " num = " << num << endl;
16
- num--;
17
- }while (num > 0 );
12
+ // num = 10;
13
+ // do
14
+ // {
15
+ // cout << "num = " << num << endl;
16
+ // num--;
17
+ // }while (num > 0);
18
18
19
- num = 10 ;
20
- while (num > 0 )
21
- {
22
- cout << " num = " << num << endl;
23
- num-- ;
24
- if ( num == 5 )
25
- break ;
26
- }
19
+ // num = 10;
20
+ // while (num > 0)
21
+ // {
22
+ // if ( num == 5)
23
+ // break ;
24
+ // cout << " num = " << num << endl;
25
+ // num-- ;
26
+ // }
27
27
return 0 ;
28
28
}
You can’t perform that action at this time.
0 commit comments