@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,
#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
@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
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
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
#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);