Hey Guys, @preetikatyagi : The question is pretty straight "Write a program printing number 1 to 100 without using any loop, GOTO statement , do while & recursion "
@sunny : We have to come up with one one logic not each time we have to change how we can add number's to make 100. It has to be with caller to decide how many number he has to print & the definition will take care of algorithm. *Subhransu Panigrahi * *Mobile:* *+91-9840931538* *Email:* [email protected] 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. > > -- 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.
