#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    15
    Rep Power
    0

    No output problem


    #include<stdio.h>
    int main()
    {
    int i=0;
    while(i++!=0)
    printf("%d",++i);
    printf("\n");
    return 0;
    }
    there is no compilation error.. then why is there no output in this ??
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    India
    Posts
    95
    Rep Power
    4
    writing ur code in different way.
    Code:
    #include<stdio.h>
    int main()
    {
    int i=0;
    while(i!=0)
    {
    i=i+1;
    printf("%d",++i);
    }
    printf("\n");
    return 0;
    }
    you should write ++i instead of i++ then it will give u output.
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,905
    Rep Power
    481
    Hope you know where to find the interrupt or kill or taskkill switch.

    i++
    is the value of i before incrementing i.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    15
    Rep Power
    0
    there is still no output !
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    India
    Posts
    95
    Rep Power
    4
    ^^^have u used ++i instead of i++???
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    15
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Hope you know where to find the interrupt or kill or taskkill switch.

    i++
    is the value of i before incrementing i.
    thanks ! got it
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    15
    Rep Power
    0
    Originally Posted by eramit2010
    ^^^have u used ++i instead of i++???
    no earlier i just ran your code.. figured the error. thanks
  14. #8
  15. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,114
    Rep Power
    1803
    Originally Posted by akha
    no earlier i just ran your code..
    His code was an exact equivalent to yours simply rewritten to illustrate why it could not work.

IMN logo majestic logo threadwatch logo seochat tools logo