Wednesday, September 15, 2010

Write program which executes a function(main or any function) to infinite times without any iteration and conditional statements.

There only two ways to execute program to  infinite number of times:

1. Using iteration or conditional statement.
2.Recursive functuion-function calls itself.

So,if iteration or conditional statement are not used, then recursive is another go...using recursive function we can write main() function as follows.

main()
{
printf("Hello world\n");
main();
}

Output:

Hello world is printed infinte number of times, till u break the program. 

No comments:

Post a Comment