Write a C program to print “GfG” repeatedly without using loop, recursion and any control structure?
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?
Examples:
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.
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf ( "GFG" );
system ( "test" );
return 0;
}
|
Output: It will print GFG infinitely.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...