Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Location
    India
    Posts
    6
    Rep Power
    0

    Unhappy using for loop...pls help

    1 3 5 7 9 //series to be printed

    printing the above sequence seems easy...but while doing so i got the following error..

    Syntax error on token "+", invalid AssignmentOperator


    pls help..
    the code i wrote was

    int i;
    for(i=1;i<=10;i+2)
    sop(i);

  2. #2
    shinjan is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default

    it's very natural that you will get this error...
    in the for loop you have not given i=i+2...write as follows[the part you have omitted is highlighted]:-
    int i;
    for(i=1;i<=10;i=i+2)
    sop(i);

  3. #3
    Join Date
    Dec 2009
    Location
    India
    Posts
    6
    Rep Power
    0

Similar Threads

  1. Which loop to use?
    By meee in forum New To Java
    Replies: 1
    Last Post: 09-07-2009, 10:36 AM
  2. while-loop stopping on first loop
    By davester in forum New To Java
    Replies: 6
    Last Post: 06-26-2009, 09:46 PM
  3. Loop, is it what I need?
    By dbashby in forum New To Java
    Replies: 4
    Last Post: 04-14-2009, 05:28 AM
  4. while loop help
    By kathyla18 in forum New To Java
    Replies: 1
    Last Post: 03-02-2009, 07:49 PM
  5. can you help me with this for loop?
    By java_fun2007 in forum New To Java
    Replies: 6
    Last Post: 12-22-2007, 11:20 AM

Tags for this Thread

Posting Permissions

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