Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Tejesh kumar.r
Date de publication: 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
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?