-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforloop.cpp
More file actions
41 lines (33 loc) · 748 Bytes
/
Copy pathforloop.cpp
File metadata and controls
41 lines (33 loc) · 748 Bytes
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
#include <iostream>
using namespace std;
int main() {
int number;
int start;
int ignore;
cout << "Enter a number: ";
cin >> number;
cout << "Give me a number to ignore: ";
cin >> ignore;
cout << "Give me a starting number: ";
cin >> start;
// Count up using while loop
int i = start;
while (i <= number) {
if (i == ignore) {
i++;
continue;
} else {
cout << i << " ";
}
i++;
}
cout << "\n";
// Count down using for loop
for (int j = number; j >= start; j--) {
if (j == ignore) {
continue; // skip the ignore number
}
cout << j << " ";
}
return 0;
}