mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

C++ a good code

3 posters

Go down

C++ a good code Empty C++ a good code

Post  shivang Wed Feb 25, 2009 4:45 pm

i came across a gud code to print n natural numbers without the use of loop
Code:
#include<iostream>
#include<cstdlib>
using namespace std;

int (*func[2])(int, char **);
int my_exit(int n, char **);

int main(int n=1, char** x = NULL)
{
static int i = 0;
cout<<endl<<n;
func[0]=&my_exit;
func[1]=&main;
i = ++n <= 10;
(func[i])(n, NULL);
}

int my_exit(int n = 1, char **y = NULL) {
        exit(0);
}



Last edited by Beagle on Fri Mar 06, 2009 7:23 pm; edited 1 time in total (Reason for editing : The code was not correct.)
shivang
shivang

Posts : 42
Join date : 2009-01-30
Age : 35

Back to top Go down

C++ a good code Empty Re: C++ a good code

Post  mnnit.rahul Sun Mar 01, 2009 7:06 pm

yaar but ye run kaise ho raha hai?

mnnit.rahul

Posts : 51
Join date : 2009-02-01

Back to top Go down

C++ a good code Empty Re: C++ a good code

Post  ramthegreatcv Tue Mar 03, 2009 12:36 am

its recursively calling main... i haven't run it myself... but i think it should work fine
ramthegreatcv
ramthegreatcv

Posts : 55
Join date : 2009-01-30
Age : 35

Back to top Go down

C++ a good code Empty Re: C++ a good code

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum