C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help to write a programm to print 1 to 100 without using if Posted by rizviiqubal on 1 May 2006 at 3:44 AM
anyone help me to write a program to print 1 to 100 without using if for etc ....


rizvi
Report
Re: help to write a programm to print 1 to 100 without using if Posted by AsmGuru62 on 1 May 2006 at 4:33 AM
: anyone help me to write a program to print 1 to 100 without using if for etc ....
:
:
: rizvi
:
printf ("\n1");
printf ("\n2");
printf ("\n3");
printf ("\n4");
printf ("\n5");
...  // 94 times more and you are done!
printf ("\n100");

Report
Re: help to write a programm to print 1 to 100 without using if Posted by tom_sw on 2 May 2006 at 8:44 AM
: : anyone help me to write a program to print 1 to 100 without using if for etc ....
: :
: :
: : rizvi
: :
:
: printf ("\n1");
: printf ("\n2");
: printf ("\n3");
: printf ("\n4");
: printf ("\n5");
: ...  // 94 times more and you are done!
: printf ("\n100");
: 

:
or: (Not tested - needs to be fleshed out a bit......)
void printr(int val)
{
    printf ("%d\n", val++);
    val < 100 ? printr(val) : ;
}

int main()
{
    printr(1);
}

Report
Re: help to write a programm to print 1 to 100 without using if Posted by tsagld on 22 May 2006 at 3:32 AM
: : : anyone help me to write a program to print 1 to 100 without using if for etc ....
: : :
: : :
: : : rizvi
: : :
: :
: : printf ("\n1");
: : printf ("\n2");
: : printf ("\n3");
: : printf ("\n4");
: : printf ("\n5");
: : ...  // 94 times more and you are done!
: : printf ("\n100");
: : 

: :
: or: (Not tested - needs to be fleshed out a bit......)
:
: void printr(int val)
: {
:     printf ("%d\n", val++);

:     val < 100 ? printr(val) : ;
that's an if...

There is no other way than AsmGuru's code.

: }
: 
: int main()
: {
:     printr(1);
: }
: 

:


Greets,
Eric Goldstein
http://www.gvh-maatwerk.nl


Report
Re: help to write a programm to print 1 to 100 without using if Posted by islam ahmad on 29 Jun 2006 at 1:28 AM
: : : : anyone help me to write a program to print 1 to 100 without using if for etc ....
: : : :
: : : :
: : : :



#include<stdio.h>
void main()
{
int i;
for(i=1;1<=100;i++)
{
printf("%d\n",i);
}
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.