Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to write a c program to implement infinite loop without using while/for statement and user defined recursion function?

user-image
Question added by Tejesh kumar.r
Date Posted: 2013/10/10

 

By using main we can able to implement infinite loop as i shown below..

 

#include<stdio.h>

void main()

{

printf("Hello");

main();

}

by using recursion functions  we can implement infinite loop

main()

{

          abc : 

           if(condition)

               goto bcd:

          statements;

          goto abc;

         bcd: 

}

Above sample code will give you control over infinite loop without using looping statements.

Wisam Kabli
by Wisam Kabli , Sec. Mgr. IT Business Partner , Saudi Arabian Ailines

#include<stdio>

using namespace std;

void main()

{

cout<<"~";

main();

}

 

//that will print "~" infinitly, another way is by making a false condition recursion.

#include<stdio.h>

void main()

{

main();

}

mahmoud Gamal
by mahmoud Gamal , Solutions Manager , We - Telecom Egypt

#include<stdio.h>

 

void main()

 

{

LL:

 

printf("hello world");

goto LL;

 

}

#include<stdio.h>

void main()

{

printf("hello world");

main();

}

 

Output: Infinite time it will print "hello world" on the screen.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.