![]() |
Are you a great C coder? | Feb. 13, 2010
one day I and my friend were wondering what if C had no "Loops" ? Suppose C language has no "loops"(while, forloop, do while loop). Now, how are you going to implement a loop logic in C without while, for loop and do while loop ?? Explain with example..
:):):):):) |
Re: Are you a great C coder?
Approved
|
Re: Are you a great C coder? | Feb. 13, 2010
Use if and goto. Not tested, cos I rarely use gotos:
Code:
int i=0; |
Re: Are you a great C coder? | Feb. 13, 2010
dnt use GOTO...goto is not structured...
|
Re: Are you a great C coder? | Feb. 13, 2010
shabbir...wud u continue this? I think noone is able to give the ans...
|
Re: Are you a great C coder? | Feb. 13, 2010
Lets do it buddy
|
Re: Are you a great C coder? | Feb. 13, 2010
Answer must be tail recursion then:
Code:
void test2a(int i) |
Re: Are you a great C coder? | Feb. 13, 2010
Quote:
Tail recursion is the only way to implement loop logic.. this process is used in PLT scheme.Take another example from me:- Code:
# include<stdio.h> |
Re: Are you a great C coder? | Feb. 13, 2010
Only if you've got enough stack space. If you haven't then you have to (a) use goto or (b) unroll the loop.
|
Re: Are you a great C coder? | Feb. 13, 2010
Quote:
Have you seen your Visitor Message? |
| All times are GMT +5.5. The time now is 22:34. |