Re: [algogeeks] Print 1 to n one per each line on the standard output

2010-09-26 Thread aswath G B
@coolfrog$

I think this can match ur requirements not even indirect recursion

#includeiostream
using namespace std;
static int i;
class sample
{
public:
sample()
{
 i=i+1;
 couti\n;
}
};
main()
{
int n;
coutEnter n\n;
cinn;
sample s[n];
return 0;
}

tats it

On Thu, Sep 23, 2010 at 11:29 PM, coolfrog$ dixit.coolfrog.div...@gmail.com
 wrote:

 @aswath :
  nice solution... very simple too.
 it gives the desired solution as required..though it is a case of indirect
 recursion... but still a nice aproach...
 keep it up
 thanks.
 Regards
 Divesh

 On Thu, Sep 23, 2010 at 12:45 PM, aswath G B aswat...@gmail.com wrote:

 #includestdio.h
 void f1(int);
 void f2(int);
 int val;
 main()
 {
 printf(Enter number\n);
 scanf(%d,val);
 f1(1);
 return 0;
 }
 void f1(int m)
 {
  if(m = val)
  {
   printf(%d\n,m);
   m++;
   f2(m);
  }
 }
 void f2(int n)
 {
  if(n = val)
  {
   printf(%d\n,n);
   n++;
   f1(n);
  }
 }

 I think this prog is correct
 which satisfies ur requirements

 On Wed, Sep 22, 2010 at 9:19 PM, Divesh Dixit 
 dixit.coolfrog.div...@gmail.com wrote:

 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
http://aswath78.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Print 1 to n one per each line on the standard output

2010-09-23 Thread aswath G B
#includestdio.h
void f1(int);
void f2(int);
int val;
main()
{
printf(Enter number\n);
scanf(%d,val);
f1(1);
return 0;
}
void f1(int m)
{
 if(m = val)
 {
  printf(%d\n,m);
  m++;
  f2(m);
 }
}
void f2(int n)
{
 if(n = val)
 {
  printf(%d\n,n);
  n++;
  f1(n);
 }
}

I think this prog is correct
which satisfies ur requirements

On Wed, Sep 22, 2010 at 9:19 PM, Divesh Dixit 
dixit.coolfrog.div...@gmail.com wrote:

 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Print 1 to n one per each line on the standard output

2010-09-23 Thread coolfrog$
@aswath :
 nice solution... very simple too.
it gives the desired solution as required..though it is a case of indirect
recursion... but still a nice aproach...
keep it up
thanks.
Regards
Divesh

On Thu, Sep 23, 2010 at 12:45 PM, aswath G B aswat...@gmail.com wrote:

 #includestdio.h
 void f1(int);
 void f2(int);
 int val;
 main()
 {
 printf(Enter number\n);
 scanf(%d,val);
 f1(1);
 return 0;
 }
 void f1(int m)
 {
  if(m = val)
  {
   printf(%d\n,m);
   m++;
   f2(m);
  }
 }
 void f2(int n)
 {
  if(n = val)
  {
   printf(%d\n,n);
   n++;
   f1(n);
  }
 }

 I think this prog is correct
 which satisfies ur requirements

 On Wed, Sep 22, 2010 at 9:19 PM, Divesh Dixit 
 dixit.coolfrog.div...@gmail.com wrote:

 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Print 1 to n one per each line on the standard output

2010-09-22 Thread Divesh Dixit
Write an algorithm that will print 1 to n, one per each line on the
standard output, where n is
a integer parameter to the algorithm. An algorithm should not use
while, for, do-while
loops, goto statement, recursion, and switch statement.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Print 1 to n one per each line on the standard output

2010-09-22 Thread Nishant Agarwal
void print_number(int n)
{ if(n=100)
  { printf(%d\n,n); print_number(n+1);}
}
main()
{ int n=1; print_number(n);}

this code is using recursion only.not loops, goto and switch
if anyone can do it without recursion then please post ur algo...
On Wed, Sep 22, 2010 at 9:19 PM, Divesh Dixit 
dixit.coolfrog.div...@gmail.com wrote:

 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
 :-)
*
Nishant Agarwal
Computer Science and Engineering
NIT Allahabad
*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Print 1 to n one per each line on the standard output

2010-09-22 Thread balaji Ruler
#includeconio.h
#includestdio.h
void main()
{
int n,no=1;
clrscr();
printf(enter the limit:);
scanf(%d,n);
printf(%d\n,no);
while(no++n)
printf(%d\n,no);
getch();
}

On 9/22/10, Nishant Agarwal nishant.agarwa...@gmail.com wrote:
 void print_number(int n)
 { if(n=100)
   { printf(%d\n,n); print_number(n+1);}
 }
 main()
 { int n=1; print_number(n);}

 this code is using recursion only.not loops, goto and switch
 if anyone can do it without recursion then please post ur algo...
 On Wed, Sep 22, 2010 at 9:19 PM, Divesh Dixit 
 dixit.coolfrog.div...@gmail.com wrote:

 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
  :-)
 *
 Nishant Agarwal
 Computer Science and Engineering
 NIT Allahabad
 *

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
  :(*Livin wit hope*:(

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.