C++ Program to Print First N Numbers using While Loop

C++ Program to Print First N Numbers using While Loop

Write C++ Program to Print First N Numbers using While Loop

// CPP Program to Print First N Numbers using While Loop

#include <iostream>

using namespace std;

int main()
{
	int n;

	cout << "Enter the number :--> ";
	cin >> n;

	int i = 1;

	while(i <= n)
	{
		cout << i << endl;
		i++;
	}

	return 0;
}

Output:

Enter the number :--> 10
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10