Re: [algogeeks] Re: printing without loop

2011-03-06 Thread Srinivas Baravatula
hi all, i really liked the answers of sunny, and sachin midha gr8 answers. but i guess as per the requirement, sachin's answer is perfect. B.Srinivas B.E. Computer engineering Mumbai University On Sat, Mar 5, 2011 at 5:55 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote: funny but correct ,i

[algogeeks] Re: printing without loop

2011-03-06 Thread Ruturaj
Using GOTO and loops it the same, cause loops are expanded to GOTO/JMP statements. Doing it just with recursion is interesting. Try sorting number without using loops or goto. Here is the complete problem. Take in n numbers as input and sort them, without using dowhile, while, for or goto. No

[algogeeks] Re: printing without loop

2011-03-06 Thread yogesh kumar
@ Ruturaj: Your Problem's Solution.. :) public class Sorting { public static void main(String arg[]) { int[] a = {2,4,5,1,7,3}; a = checkNumber(0,1,a); // to Print an Array for(int k=0;ka.length;k++)

Re: [algogeeks] Re: printing without loop

2011-03-05 Thread Bhavesh agrawal
funny but correct ,i have a code of 100 lines of file named b.cpp so i use awk script to print only no. of lines and i got the exact desired result . #includecstdlib using namespace std; int main() { system(awk '{print NR}' b.cpp); } -- You received this message because you are subscribed

[algogeeks] Re: printing without loop

2011-03-02 Thread Sachin Midha
The method that I have given you, can print as many numbers as you want, depending upon how many objects you create. Yes with this method you'll have to create 100 objects of the dummy class, that can be easily created using dummy d[100] So that makes the method very effective shows how much

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Nishant Agarwal
use recursion. On Tue, Mar 1, 2011 at 5:13 PM, bittu shashank7andr...@gmail.com wrote: here we go void main() { int i; i=1; loop: printf(%d, i) (i100)? i++: return 0; go to loop; } Thanks Regards Shashank Mani The Best Way to Escape From The Problem is to Solve it --

[algogeeks] Re: printing without loop

2011-03-01 Thread Sachin Midha
Hey all... I have another method, which will use the power of c++... class dummy{ static int objectCount; dummy(){ cout ++objectCount endl; } } int dummy::objectCount = 0; Now create as many objects as required, and as you create a new object, the total count of objects instantiated till now

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
#includeiostream int i=1; int main() { printf(%d\n,i++); return i==100?0:main(); } -- Himanshu Sachdeva -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
should be i==101 instead. On 3/1/11, Himanshu Sachdeva himansh.sachd...@gmail.com wrote: #includeiostream int i=1; int main() { printf(%d\n,i++); return i==100?0:main(); } -- Himanshu Sachdeva -- Himanshu Sachdeva -- You received this message because you are subscribed to the

[algogeeks] Re: printing without loop

2011-03-01 Thread Sachin Midha
Rather than iostream, include stdio.h, because we can't call main() from main() in c++, but we can do that in C. Best Regards, Sachin Midha On Mar 1, 10:49 pm, Himanshu Sachdeva himansh.sachd...@gmail.com wrote: #includeiostream int i=1; int main() { printf(%d\n,i++); return

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread MANNU
@himanshu: you are using recursive call. And in problem it is mentioned that you can't use recursion. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Himanshu Sachdeva
Sorry. Didn't read the problem statement correctly. On 3/1/11, MANNU manishkr2...@gmail.com wrote: @himanshu: you are using recursive call. And in problem it is mentioned that you can't use recursion. -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread gaurav gupta
@bittu please read the thread carefully. It was mentioned not to use GOTO statement. On Tue, Mar 1, 2011 at 5:13 PM, bittu shashank7andr...@gmail.com wrote: here we go void main() { int i; i=1; loop: printf(%d, i) (i100)? i++: return 0; go to loop; } Thanks Regards Shashank

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread gaurav gupta
how will you create 100 objects of dummy class. Can you write pseudo code for that? On Tue, Mar 1, 2011 at 11:11 PM, Sachin Midha sachinmidha1...@gmail.comwrote: Hey all... I have another method, which will use the power of c++... class dummy{ static int objectCount; dummy(){ cout

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread gaurav gupta
So do you want to say the code below is not using recursion? #includeiostream int i=1; int main() { printf(%d\n,i++); return i==100?0:main(); } On Tue, Mar 1, 2011 at 11:27 PM, Sachin Midha sachinmidha1...@gmail.comwrote: Rather than iostream, include stdio.h, because we can't call main()