Re: [algogeeks] Print 1 to n without loops

2011-06-11 Thread /\/a|-|a/\/t
use goto On Sat, Jun 11, 2011 at 8:55 PM, hary rathor wrote: > int main() > { > static int i=1; > int n=100; > if(i<=n) > { > printf("%d ",i); > i++; > main(); > } > return 0; > } > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To p

Re: [algogeeks] Print 1 to n without loops

2011-06-11 Thread hary rathor
int main() { static int i=1; int n=100; if(i<=n) { printf("%d ",i); i++; main(); } return 0; } -- 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 group, se

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread nicks
this problem was discussed some time before on this group i am picking up a solution discussed there which you would love to see int i=1; #define PRINT1 cout sorry i meant 'constructor' ! > > On Fri, Jun 10, 2011 at 9:40 PM, Radhika Renganathan < > radi.coo...@gmail.com> wrote: > >>

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Radhika Renganathan
sorry i meant 'constructor' ! On Fri, Jun 10, 2011 at 9:40 PM, Radhika Renganathan wrote: > we can declare a class with construction printing value > > class A > { > private: > static int i; > public: > A() > { > cout<<++i < } > }; > A::i=0; > main() > { > int n=5; > A ob[n]; > } > this will prin

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Good Answer Radhika. You are correct. On Fri, Jun 10, 2011 at 9:40 PM, Radhika Renganathan wrote: > we can declare a class with construction printing value > > class A > { > private: > static int i; > public: > A() > { > cout<<++i < } > }; > A::i=0; > main() > { > int n=5; > A ob[n]; > } > this w

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Radhika Renganathan
we can declare a class with construction printing value class A { private: static int i; public: A() { cout<<++i Using recursion would be like using loops only. Also i believe the > recursion used would be tail recursion and one can change tail recursion to > loop based non recursive me

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Using recursion would be like using loops only. Also i believe the recursion used would be tail recursion and one can change tail recursion to loop based non recursive method. Okay, giving all a hint. Think classes and objects. On Fri, Jun 10, 2011 at 9:26 PM, Navneet Gupta wrote: > No. > > > On

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
No. On Fri, Jun 10, 2011 at 9:26 PM, nagajyothi gunti < nagajyothi.gu...@gmail.com> wrote: > > Can "goto" statement be used? > > On Fri, Jun 10, 2011 at 11:42 AM, Navneet Gupta wrote: > >> Take n from user and print 1 to n. No loops like for/while/do-while are >> allowed to use. >> >> --Navneet >

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Kunal Patil
IF allowed ??? If yes...Use recursion.. On Fri, Jun 10, 2011 at 9:12 PM, Navneet Gupta wrote: > Take n from user and print 1 to n. No loops like for/while/do-while are > allowed to use. > > --Navneet > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread nagajyothi gunti
Can "goto" statement be used? On Fri, Jun 10, 2011 at 11:42 AM, Navneet Gupta wrote: > Take n from user and print 1 to n. No loops like for/while/do-while are > allowed to use. > > --Navneet > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" gr

[algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use. --Navneet -- 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 group