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 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()
  return 0;

Output: 100 times 1.


Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar