C++ Program to Print First n Numbers using For Loop

Write C++ Program to Print First n Numbers using For Loop

// CPP Program to Print First n Numbers using For Loop

#include <iostream>

using namespace std;

int main()
{
	int n;

	cout << "Enter Number :--> ";
	cin >> n;

	int i;


        cout << "\nFirst " << n << " Numbers :--> ";
	for(i=1; i<=n; i++)
	{
		cout << i << " ";
	}

	return 0;
}

Output:

Enter Number :--> 10

First 10 Numbers :-->  1  2  3  4  5  6  7  8  9  10

≪ Previous | Next ≫