-
Notifications
You must be signed in to change notification settings - Fork 1
/
ForLoopHR.cpp
88 lines (77 loc) · 1.96 KB
/
ForLoopHR.cpp
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
/*
A for loop is a programming language statement which allows code to be repeatedly executed.
The syntax for this is
for ( <expression_1> ; <expression_2> ; <expression_3> )
<statement>
expression_1 is used for intializing variables which are generally used for controlling terminating flag for the loop.
expression_2 is used to check for the terminating condition. If this evaluates to false, then the loop is terminated.
expression_3 is generally used to update the flags/variables.
A sample loop will be
for(int i = 0; i < 10; i++) {
...
}
Input Format
You will be given two positive integers, and (), separated by a newline.
Output Format
For each integer in the interval :
If , then print the English representation of it in lowercase. That is "one" for , "two" for , and so on.
Else if and it is an even number, then print "even".
Else if and it is an odd number, then print "odd".
Note:
Sample Input
8
11
Sample Output
eight
nine
even
odd
*/
// SOLUTION
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
// Complete the code.
int start,end;
cin>>start;
cin>>end;
for(int n = start;n <= end; n++){
if(n <= 9){
if(n == 1){
cout<<"one\n";
}
else if(n == 2){
cout<<"two\n";
}
else if(n == 3){
cout<<"three\n";
}
else if(n == 4){
cout<<"four\n";
}
else if(n == 5){
cout<<"five\n";
}
else if(n == 6){
cout<<"six\n";
}
else if(n == 7){
cout<<"seven\n";
}
else if(n ==8){
cout<<"eight\n";
}
else if(n == 9){
cout<<"nine\n";
}
}
else if( n % 2 == 0){
cout<<"even\n";
}
else{
cout<<"odd\n";
}
}
return 0;
}