Count to N

Lab C++ Beginner 10 points

Read n and print 1 to n separated by spaces.

Input

One integer ≥ 1.

Output

One line.

Example

Input

5

Output

1 2 3 4 5
Sample input available Sample output available
Editor
C++

Hints

Print a space after every number except the last.

Solution explanation

The conditional operator picks the separator.

Show solution
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cout << i << (i < n ? " " : "\n");
    }
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD