Skip to content

Commit 1c7329f

Browse files
committed
Natural number sequence program added in CPP
1 parent 602dd85 commit 1c7329f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int start, end;
6+
cout << "Enter your starting number : " << endl;
7+
cin >> start;
8+
cout << "Enter your end number : " << endl;
9+
cin >> end;
10+
if (start <= 0 || end <= 0)
11+
cout << "A Natural Number can't be negative, fractional or equal to zero.." << endl;
12+
else if (end < start)
13+
cout << "End Number should be larger than starting number" << endl;
14+
else
15+
{
16+
for (int i = start; i <= end; i++)
17+
{
18+
cout << i << " ";
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)