ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Tejesh kumar.r
تاريخ النشر: 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
من قبل 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.

mahmoud Gamal
من قبل mahmoud Gamal , Solutions Manager , We - Telecom Egypt

#include<stdio.h>

 

void main()

 

{

LL:

 

printf("hello world");

goto LL;

 

}

Tejesh kumar.r
من قبل Tejesh kumar.r

#include<stdio.h>

void main()

{

printf("hello world");

main();

}

 

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

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟