How to print N times without using loops or recursion ? Last Updated : 12 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice How to print "Hello" N times (where N is user input) without using loop or recursion or goto. Input : N, that represent the number of times you want to print the statement. Output : Statement for N times First, we create a class. After that, we need to initialize the constructor of the class by writing the statement you want to print inside a cout/print statement. The basic idea used here that "The no. of times you create the object of the class, the constructor of that class is called that many times." CPP // CPP program to print a sentence N times // without loop and recursion. // Author : Rohan Prasad #include <iostream> using namespace std; class Print { public: Print() { cout << "Hello" << endl; } }; int main() { int N = 5; Print a[N]; return 0; } Python3 class Print: def __init__(self): print("Hello") N = 5 a = [Print() for i in range(N)] Output:Hello Hello Hello Hello Hello Time Complexity: O(N) Auxiliary Space: O(N) Extra space is required for array initialisation. Comment More infoAdvertise with us Next Article How to print N times without using loops or recursion ? L Logarithm Follow Improve Article Tags : DSA Similar Reads Print 1 to n without using loops You are given an integer n. Print numbers from 1 to n without the help of loops.Examples:Input: N = 5Output: 1 2 3 4 5Explanation: We have to print numbers from 1 to 5.Input: N = 10Output: 1 2 3 4 5 6 7 8 9 10Explanation: We have to print numbers from 1 to 10.Approach: Using RecursionTo solve the pr 2 min read Print 1 to 100 in C++ Without Loops and Recursion We can print 1 to 100 without using loops and recursion using three approaches discussed below: 1) Template Metaprogramming: Templates in C++ allow non-datatypes also as parameters. Non-datatype means a value, not a datatype. Example: CPP // CPP Program to print 1 to 100 // without loops and recursi 3 min read Print N to 1 without loop You are given an integer N. Print numbers from N to 1 without the help of loops. Examples: Input: N = 5Output: 5 4 3 2 1Explanation: We have to print numbers from 5 to 1. Input: N = 10Output: 10 9 8 7 6 5 4 3 2 1Explanation: We have to print numbers from 10 to 1. Approach: If we take a look at this 3 min read Print numbers 1 to N using Indirect recursion Given a number N, we need to print numbers from 1 to N with out direct recursion, loops, labels. Basically we need to insert in above code snippet so that it can be able to print numbers from 1 to N? C #include <stdio.h> #define N 20; int main() { // Your code goes Here. } Examples :  Input 5 min read How will you print numbers from 1 to 100 without using a loop? If we take a look at this problem carefully, we can see that the idea of "loop" is to track some counter value, e.g., "i = 0" till "i <= 100". So, if we aren't allowed to use loops, how can we track something in the C language?Well, one possibility is the use of 'recursion', provided we use the t 12 min read Like