Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Write a C program to print “GfG” repeatedly without using loop, recursion and any control structure?

  • Difficulty Level : Easy
  • Last Updated : 11 Oct, 2018

As we all know the concept of printing the given string repeatedly using various loops(for loop,while loop),recursion and some control structure also. But the question is how we will print the given string repeatedly i.e. infinitely without using any loops,recursion and any control structure?


Input  : GFG
Output : GFGGFGGFGGFG...(It will print GFG infinitely).

The idea is to use system() to call the program itself. While compiling, we pass the executable file name “test”. We call system(test) which will execute the same program repeatedly, because system is a function which executes extern commands or executable files.

// The program is compiled using -O option
// to produce output executable file name
// as "test"
int main()
    return 0;

Output: It will print GFG infinitely.

This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!