Thread: How coding -WHILE

  1. #1
    Registered User hakimstm1b's Avatar
    Join Date
    Sep 2010
    Posts
    30

    How coding -WHILE

    #include<stdio.h>
    main()
    {
    int i=0;

    while(i<=9)
    {

    printf("Valuea i is :%d\n",i);

    *any one no what formula can i use here to make it mutiple 2 *


    }

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    1) This is the 21st century, so it's int main(void) not just main().

    2) main is supposed to return an integer, 0 in your case.

    3) you probably want to do i = i*2 to multiply i by two and store the result back into i.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    Registered User hakimstm1b's Avatar
    Join Date
    Sep 2010
    Posts
    30
    Quote Originally Posted by claudiu View Post
    1) This is the 21st century, so it's int main(void) not just main().

    2) main is supposed to return an integer, 0 in your case.

    3) you probably want to do i = i*2 to multiply i by two and store the result back into i.
    thank

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    << !! Posting Code? Read this First !! >>
    Read it before you post any more code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User hakimstm1b's Avatar
    Join Date
    Sep 2010
    Posts
    30
    #include<stdio.h>
    main()
    {
    int i=9;

    while(i<=1)
    {

    printf("Valuea i is :%d\n",i);

    *any one no what formula can i use here to make it decreasea by 2*


    }

    how to make it decreasa by 2?

  6. #6
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Quote Originally Posted by Salem View Post
    << !! Posting Code? Read this First !! >>
    Read it before you post any more code.
    Hi I'd like to help you, but the moderator asked you to stop posting
    code (incorrectly) until you read the link provided.

    I don't think you read it, because you're still not using code tags.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by hakimstm1b View Post
    #include<stdio.h>
    main()
    {
    int i=9;

    while(i<=1)
    {

    printf("Valuea i is :%d\n",i);

    *any one no what formula can i use here to make it decreasea by 2*


    }

    how to make it decreasa by 2?
    Are you... serious?

  8. #8
    Registered User hakimstm1b's Avatar
    Join Date
    Sep 2010
    Posts
    30
    post incorrect whre i do wrong?

  9. #9
    Registered User hakimstm1b's Avatar
    Join Date
    Sep 2010
    Posts
    30
    int i=10;

    while(i<=2)
    {

    printf("Valuea i is :%d\n",i);

    *any one no what formula can i use here to make it decreasea by 2*


    }

    how to make it decreasa by 2?

  10. #10
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by hakimstm1b View Post
    int i=10;

    while(i<=2)
    {

    printf("Valuea i is :%d\n",i);

    *any one no what formula can i use here to make it decreasea by 2*


    }

    how to make it decreasa by 2?
    Maybe you should go to a forum in a language you actually speak. I mean, your questions are horrible because of so many reasons and any explanation given to you about what makes is so wrong you either don't read or don't understand.

  11. #11
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198
    Quote Originally Posted by EVOEx View Post
    Maybe you should go to a forum in a language you actually speak. I mean, your questions are horrible because of so many reasons and any explanation given to you about what makes is so wrong you either don't read or don't understand.
    EVoEX Please please be a little more considerate of someone trying to get help
    from a non-native English country. I can understand her 99%. The fact that she is fluent
    in her native language, and she can communicate in English, makes her a lot smarter than
    me, IMHO.
    Last edited by Char*Pntr; 10-15-2010 at 06:03 PM.

  12. #12
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198

    Smile

    Quote Originally Posted by hakimstm1b View Post
    post incorrect whre i do wrong?
    Hi hakimastm, here's how you do it. you post your code between these 2 blocks.

    [code xxx] put your code here [/code xxx]


    Don't include the "xxx" ... I put those in there otherwise you could not see
    what wrote.

    Take out the "xxx" and try again. :-)

    EDIT: I'm copying and pasting the example from the moderator's link:

    How do I use code tags?
    Well if you have any experience with HTML it is fairly simple to use. A tag has a beginning and ending. A beginning tag looks like this: [tag] and an ending tag looks like this: [/tag xxx] . The tag name for the code tag is simple, it is "code". So to begin a code tag, type the following: [code] . Then type all your code or copy and paste, whatever you want. When you are done, use the closing tag which uses the same tag name but with a forward slash to denote a closed tag: [/code] .
    Last edited by Char*Pntr; 10-15-2010 at 06:13 PM. Reason: additional info

  13. #13
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Spoon feed me! Do my homework! I have an avatar of a GIRL!!!

    /rolleyes

  14. #14
    Registered User Char*Pntr's Avatar
    Join Date
    Sep 2007
    Location
    Lathrop, CA
    Posts
    198

    Smile

    Quote Originally Posted by rags_to_riches View Post
    Spoon feed me! Do my homework! I have an avatar of a GIRL!!!

    /rolleyes
    RtoR I can relate to what you're saying, because I think I have seen
    that in other threads.

    However, there are few factors in this case which should be considered:

    1) I'm very married, happily married to a Thai lady who wrote to me English in
    exactly the same way when at the beginning we were pen pals 14 time zones away.

    2) I would have had precisely the same response to a male person in the same situation.

    RtoR I thoroughly enjoy reading your posts, and I like to learn how to detect
    cross posts, a skill that you have mastered.

    My main concern, was that a non-native English speaker is having a hard time, and I only
    wanted to help.

    Since you have your doubts, and I want to continue for us to have a good relationship
    :-) I'm done with this thread.

    Edit: Your reply was funny, and it made me laugh. I do have a sense
    of humor - so this should be proof of no hard feelings on my part. :-D
    Last edited by Char*Pntr; 10-15-2010 at 07:20 PM.

  15. #15
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Char*Pntr it wasn't meant as a criticism of you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP - Stuck on some coding
    By trueman1991 in forum C Programming
    Replies: 6
    Last Post: 10-29-2009, 12:54 PM
  2. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  3. Coding Guideline ....!!
    By imfeelingfortun in forum Tech Board
    Replies: 8
    Last Post: 10-08-2006, 07:09 AM
  4. Coding Contest....
    By Koshare in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 10-14-2001, 04:32 PM