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 program to print "1" 100 times. // Prints 1 only once #define a cout<<"1"<<endl; // Puts "a" 10 times #define b a a a a a a a a a a // Puts "b" 10 times #define c b b b b b b b b b b int main() { c; return 0; } |
Output: 100 times 1.
This article is contributed by Aditya Rakhecha. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Print a number 100 times without using loop, recursion and macro expansion in C?
- Print 1 to 100 in C++, without loop and recursion
- Write a C program to print "GfG" repeatedly without using loop, recursion and any control structure?
- How will you print numbers from 1 to 100 without using loop?
- How will you print numbers from 1 to 100 without using loop? | Set-2
- Print substring of a given string without using any string function and loop in C
- Sum of array Elements without using loops and recursion
- How to concatenate two integer arrays without using loop in C ?
- How to find length of a string without string.h and loop in C?
- Change/add only one character and print '*' exactly 20 times
- Write a C program to print "Geeks for Geeks" without using a semicolon
- Print "Even" or "Odd" without using conditional statement
- Print individual digits as words without using if or switch
- Print "Hello World" in C/C++ without using any header file
- C Program to print numbers from 1 to N without using semicolon?
- How to print a semicolon(;) without using semicolon in C/C++?
- C program to print characters without using format specifiers
- How to print range of basic data types without any library function and constant in C?
- Print 2D matrix in different lines and without curly braces in C/C++?
- Solving f(n)= (1) + (2*3) + (4*5*6) ... n using Recursion

