Try The 'C' Code !

Discussion in 'Computer Science | IT | Networking' started by Kaustubh Katdare, Jun 15, 2006.

    pradeep_agrawal Certified CEan

    Message Count:
    199
    Ratings Received:
    +0
    Engineering Discipline:
    Computer Science
    /* 1st Way: Change i in i-- by n*/
    int i, n = 20;
    for (i = 0; i < n; n--)
    {
    printf("X");
    }


    /* 2nd Way: Add - before i in i < n */
    int i, n = 20;
    for (i = 0; -i < n; i--)
    {
    printf("X");
    }


    /* 3rd Way: Change < in i < n by + */
    int i, n = 20;
    for (i = 0; i + n; i--)
    {
    printf("X");
    }

    ksrbhanu Certified CEan

    Message Count:
    3
    Ratings Received:
    +0
    Hi friends,

    I have one method, i will try other two. mean while review this method

    int i, n = 20;
    for (i = 0; i < n; n--)
    {
    printf("X");
    }

    replacing the i in the decrement statement with n it works , this is one character change :cool:

    ksrbhanu Certified CEan

    Message Count:
    3
    Ratings Received:
    +0
    sory guys, i have n't checked the whole chain , pradeep has already posted this metho :(

    spirit Certified CEan

    Message Count:
    1
    Ratings Received:
    +0
    hello.....i m giving your answer n u have to tell thats right or not.....:cool:
    this is your code........
    int i, n = 20;
    for (i = 0; i < n; i--)
    {
    printf("X");
    }
    1. instead of i-- in the loop,change it as n--.
    2.in initialisation,n=20,change it as:n=-20.
    3.instead of i--,use:i++.

    :happy:

    rahul dev choud Certified CEan

    Message Count:
    11
    Ratings Received:
    +0
    hey its really interesting don't tell da ans...

    working on it ....

    w'll back soon......

Share This Page