Results 1 to 6 of 6
  1. #1
    ahmad is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Default hello i need help

    How do I resolve this question

    Q2: Rewrite the following code using while instead of for:
    int i=0,sum=0;
    for(;i<=100;i+=2){
    if(i%5==0)
    continue;
    cout<<i;
    sum+=i;
    }
    cout<<sum;

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,413
    Rep Power
    5

    Default Re: hello i need help

    First, do you know how to write a while loop? If not, check out the tutorials in my signature.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    ahmad is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Default Re: hello i need help

    Hello Jim
    I need answer, and yes I know how to write a while loop

    Regards,
    ahmad

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,732
    Rep Power
    5

    Default Re: hello i need help

    Quote Originally Posted by ahmad View Post
    Hello Jim
    and yes I know how to write a while loop
    If that were true, you could do it yourself.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: hello i need help

    Quote Originally Posted by ahmad View Post
    Hello Jim
    I need answer,
    Then, here you go

    WE ARE NOT A HOMEWORK SERVICE!

    and

    DO YOUR OWN HOMEWORK!

    We are MORE than happy to help YOU correct YOUR work, but we are NOT going to do it for you.

    and yes I know how to write a while loop

    Regards,
    ahmad
    Okay, lets see your ATTEMPT at it then.

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,732
    Rep Power
    5

    Default Re: hello i need help

    Indeed. You ask help so you may answer it yourself, not "the answer" so you can pretend you knew it all along.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •