Print a number 100 times without using loop, recursion and macro expansion in C? Last Updated : 21 Jun, 2022 Comments Improve Suggest changes Like Article Like Report It is possible to solve this problem using loop or a recursion method. And we have already seen the solution using #define directive (Macro expansion) but what if all three are not allowed? A simple solution is to write the number 100 times in cout statement. A better solution is to use concept of Concept of setjump and longjump in C. CPP // CPP program to print one 100 times. #include <iostream> #include <setjmp.h> using namespace std; jmp_buf buf; int main() { int x = 1; // Setup jump position using buf setjmp(buf); cout << "1"; // Prints 1 x++; if (x <= 100) // Jump to the point setup by setjmp longjmp(buf, 1); return 0; } Output : 100 times 1. Time complexity : O(n) Auxiliary Space : O(1) The same can be written for C also. Comment More infoAdvertise with us Next Article Print a number 100 times without using loop, recursion and macro expansion in C? A AdityaRakhecha Improve Article Tags : Misc C/C++ Puzzles C Language C++ c-puzzle cpp-puzzle +2 More Practice Tags : CPPMisc Similar Reads How to print a number 100 times without using loop and recursion in C? It is possible to solve this problem using loop or a recursion method but what if both are not allowed? A simple solution is to write the number 100 times in cout statement. A better solution is to use #define directive (Macro expansion) CPP // CPP program to print "1" 100 times. // Prints 1 min read Print a character n times without using loop, recursion or goto in C++ Given a character c and a number n, print the character c, n times. We are not allowed to use loop, recursion, and goto. Examples : Input : n = 10, c = 'a'Output : aaaaaaaaaa Input : n = 6, character = '@'Output : @@@@@@ In C++, there is a way to initialize a string with a value. It can be used to p 2 min read Print 1 to 100 without loop using Goto and Recursive-main Our task is to print all numbers from 1 to 100 without using a loop. There are many ways to print numbers from 1 to 100 without using a loop. Two of them are the goto statement and the recursive main. Print numbers from 1 to 100 Using Goto statement Follow the steps mentioned below to implement the 5 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 C Program to Print Number series without using any loop Write a C program for given two number N and K, our task is to subtract a number K from N until number(N) is greater than zero, once the N becomes negative or zero then we start adding K until that number become the original number(N). Note: Not allow to use any loop. Examples : Input : N = 15 K = 5 2 min read Like