@Sunny nice solution. But can you generalize this for x without any loop
to be more clear write a function which prints 1 to n without any loop. print( int n ) for n how will you calculate what all PRINTk are required ? On Tue, Mar 1, 2011 at 1:27 PM, sunny agrawal <[email protected]>wrote: > int i=1; > #define PRINT1 cout<<i++<<endl; > #define PRINT2 PRINT1 PRINT1 > #define PRINT4 PRINT2 PRINT2 > #define PRINT8 PRINT4 PRINT4 > #define PRINT16 PRINT8 PRINT8 > #define PRINT32 PRINT16 PRINT16 > #define PRINT64 PRINT32 PRINT32 > > int main() > { > //as 100 = (1100100); we need to use PRINT64, PRINT32, and PRINT4 > PRINT64; > PRINT32; > PRINT4; > } > > > This will print 1 to 100. You can use this code to print from 1 to x > (x<=128). You can extend it to larger numbers, by adding PRINT128, > PRINT256...etc. > > On 3/1/11, preetika tyagi <[email protected]> wrote: > > May be we can use *goto *statement? > > > > On Mon, Feb 28, 2011 at 10:36 PM, gaurav gupta > > <[email protected]>wrote: > > > >> Questions is : You have to print 1 to n without using any loop( for, > >> while, > >> do-while, goto ) and recursion. > >> > >> Any suggestion? > >> > >> > >> On Tue, Mar 1, 2011 at 10:52 AM, preetika tyagi > >> <[email protected]>wrote: > >> > >>> Can you elaborate on it and provide more details? > >>> > >>> > >>> On Mon, Feb 28, 2011 at 10:14 PM, Subhransupanigrahi < > >>> [email protected]> wrote: > >>> > >>>> Is there any way to print 1 to 10 (taking an example, it can also > extend > >>>> to 100) without using loop, recursion. > >>>> > >>>> > >>>> Sent from my iPhone > >>>> > >>>> -- > >>>> You received this message because you are subscribed to the Google > >>>> Groups > >>>> "Algorithm Geeks" group. > >>>> To post to this group, send email to [email protected]. > >>>> To unsubscribe from this group, send email to > >>>> [email protected]. > >>>> 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 [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> For more options, visit this group at > >>> http://groups.google.com/group/algogeeks?hl=en. > >>> > >> > >> > >> > >> -- > >> Thanks & Regards, > >> Gaurav Gupta > >> 7676-999-350 > >> > >> "Quality is never an accident. It is always result of intelligent > effort" > >> - > >> John Ruskin > >> > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > > > > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards, Gaurav Gupta 7676-999-350 "Quality is never an accident. It is always result of intelligent effort" - John Ruskin -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
