help to write a programm to print 1 to 100 without using if - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help to write a programm to print 1 to 100 without using if

rizviiqubalrizviiqubal Posts: 3Member
anyone help me to write a program to print 1 to 100 without using if for etc ....


rizvi

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : anyone help me to write a program to print 1 to 100 without using if for etc ....
    :
    :
    : rizvi
    :
    [code]
    printf ("
    1");
    printf ("
    2");
    printf ("
    3");
    printf ("
    4");
    printf ("
    5");
    ... // 94 times more and you are done!
    printf ("
    100");
    [/code]
  • tom_swtom_sw Posts: 828Member
    : : anyone help me to write a program to print 1 to 100 without using if for etc ....
    : :
    : :
    : : rizvi
    : :
    : [code]
    : printf ("
    1");
    : printf ("
    2");
    : printf ("
    3");
    : printf ("
    4");
    : printf ("
    5");
    : ... // 94 times more and you are done!
    : printf ("
    100");
    : [/code]
    :
    or: (Not tested - needs to be fleshed out a bit......)
    [code]
    void printr(int val)
    {
    printf ("%d
    ", val++);
    val < 100 ? printr(val) : ;
    }

    int main()
    {
    printr(1);
    }
    [/code]
  • tsagldtsagld Posts: 621Member
    : : : anyone help me to write a program to print 1 to 100 without using if for etc ....
    : : :
    : : :
    : : : rizvi
    : : :
    : : [code]
    : : printf ("
    1");
    : : printf ("
    2");
    : : printf ("
    3");
    : : printf ("
    4");
    : : printf ("
    5");
    : : ... // 94 times more and you are done!
    : : printf ("
    100");
    : : [/code]
    : :
    : or: (Not tested - needs to be fleshed out a bit......)
    : [code]
    : void printr(int val)
    : {
    : printf ("%d
    ", val++);
    [red]
    : val < 100 ? printr(val) : ;
    that's an if...

    There is no other way than AsmGuru's code.
    [/red]
    : }
    :
    : int main()
    : {
    : printr(1);
    : }
    : [/code]
    :


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


  • islam ahmadislam ahmad Posts: 47Member
    : : : : anyone help me to write a program to print 1 to 100 without using if for etc ....
    : : : :
    : : : :
    : : : :



    #include
    void main()
    {
    int i;
    for(i=1;1<=100;i++)
    {
    printf("%d
    ",i);
    }
    }
Sign In or Register to comment.