There are several methods to print numbers without using loops like by using recursive function, goto statement and creating a function outside main() function.
Here is an example to print numbers using goto statement in C++ language,
Example
#include <bits/stdc++.h>
using namespace std;
int main() {
int count=1;
int x;
cout << "Enter the max value of x : ";
cin >> x;
PRINT:
cout << " " << count;
count++;
if(count<=x)
goto PRINT;
return 0;
}Output
Enter the max value of x : 1
In the above program, we used GOTO statement to print the numbers from 1 to 100 without using loops and recursion.
PRINT: cout << " " << count; count++; if(count<=x) goto PRINT;