Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. for(int i=0; i<size; i++)

for(int i=0; i<size; i++)

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpc++javaquestion
67 Posts 44 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T tumbledDown2earth

    I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

    G Offline
    G Offline
    gholamali Hosseini
    wrote on last edited by
    #21

    i am using 'i' and 'j' for iterating 2D arrays because 'i' and 'j' mean x and y in Cartesian coordinates. :) http://butterfly.blog.ir[^]

    Y 1 Reply Last reply
    0
    • M Matthew Bache

      If it wasn't for our coding standard, I would employ index, jndex... today. I like that idea.

      Matt

      Y Offline
      Y Offline
      YDaoust
      wrote on last edited by
      #22

      You can use it undercover by means of a macro #define i index ;-)

      1 Reply Last reply
      0
      • G gholamali Hosseini

        i am using 'i' and 'j' for iterating 2D arrays because 'i' and 'j' mean x and y in Cartesian coordinates. :) http://butterfly.blog.ir[^]

        Y Offline
        Y Offline
        YDaoust
        wrote on last edited by
        #23

        Don't they mean 'horizontal' and 'vertical' ?

        G 1 Reply Last reply
        0
        • P PIEBALDconsult

          I was using i for index before I was introduced to Fortran.

          J Offline
          J Offline
          jsc42
          wrote on last edited by
          #24

          If you were using 'i' before being introduced to FORTRAN, you must have been late being introduced. When I started, there was no lowercase! After some assemblers, FORTRAN IV (aka FORTRAN 66) was one of the first high level languages that I learnt and so I (like everybody else) used I, J, and K as loop variable names. I also used FORTRAN II at college. Shouldn't for(int i =0; i

          P 1 Reply Last reply
          0
          • Y YDaoust

            Don't they mean 'horizontal' and 'vertical' ?

            G Offline
            G Offline
            gholamali Hosseini
            wrote on last edited by
            #25

            maybe but I don't think so. horizontal -> h not 'i' & vertical ->v not 'j' the 'i' and 'j' are symbols for horizontal and vertical vectors.

            Y 1 Reply Last reply
            0
            • G gholamali Hosseini

              maybe but I don't think so. horizontal -> h not 'i' & vertical ->v not 'j' the 'i' and 'j' are symbols for horizontal and vertical vectors.

              Y Offline
              Y Offline
              YDaoust
              wrote on last edited by
              #26

              probably i -> row and j -> column then

              G 1 Reply Last reply
              0
              • Y YDaoust

                probably i -> row and j -> column then

                G Offline
                G Offline
                gholamali Hosseini
                wrote on last edited by
                #27

                :omg: Hmmmmm...

                1 Reply Last reply
                0
                • B Brady Kelly

                  But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'. Yes, dataset.Tables[1] will work, but why, oh the humanity, why, are you not using the table name?

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #28

                  Brady Kelly wrote:

                  But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'.

                  Bad habits from the type writer era. http://www.flickr.com/photos/textlad/3564672292/[^]

                  Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                  1 Reply Last reply
                  0
                  • T tumbledDown2earth

                    I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                    W Offline
                    W Offline
                    WPerkins
                    wrote on last edited by
                    #29

                    I think you are right. If not otherwise defined FORTRAN would default to integer variables whose names started with "I" through "l" (ell) I believe. Not too sure about the ending letter as all *good* programmers defined their variables. After years of programming I still use "t" for temporary variables (like creating a value for the debugger to see) and "t.t" for file names for the same sort of thing - temporary names while developing. This comes from the old TRS80 system. Old habits die hard, eh?

                    T H 2 Replies Last reply
                    0
                    • T tumbledDown2earth

                      I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                      F Offline
                      F Offline
                      fredrick72
                      wrote on last edited by
                      #30

                      I always use index and sometimes preppend it with the object or value i am indexing. It leads to a bit more verbose code but it is a hell of a lot easier to understand. Just my opinion.

                      1 Reply Last reply
                      0
                      • T tumbledDown2earth

                        I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                        M Offline
                        M Offline
                        mc42
                        wrote on last edited by
                        #31

                        Yes, it started in FORTRAN and leads to the following joke: God is real unless declared integer At least now you have the context so you can see the humor :)

                        R 1 Reply Last reply
                        0
                        • W WPerkins

                          I think you are right. If not otherwise defined FORTRAN would default to integer variables whose names started with "I" through "l" (ell) I believe. Not too sure about the ending letter as all *good* programmers defined their variables. After years of programming I still use "t" for temporary variables (like creating a value for the debugger to see) and "t.t" for file names for the same sort of thing - temporary names while developing. This comes from the old TRS80 system. Old habits die hard, eh?

                          T Offline
                          T Offline
                          tumbledDown2earth
                          wrote on last edited by
                          #32

                          same thoughts

                          1 Reply Last reply
                          0
                          • M Matthew Bache

                            If it wasn't for our coding standard, I would employ index, jndex... today. I like that idea.

                            Matt

                            R Offline
                            R Offline
                            Rob Grainger
                            wrote on last edited by
                            #33

                            Why not just skip to "spa"

                            1 Reply Last reply
                            0
                            • M mc42

                              Yes, it started in FORTRAN and leads to the following joke: God is real unless declared integer At least now you have the context so you can see the humor :)

                              R Offline
                              R Offline
                              Rob Grainger
                              wrote on last edited by
                              #34

                              Sorry, I still don't see the humour! (Sound of tumbleweed blowing)

                              M 1 Reply Last reply
                              0
                              • T tumbledDown2earth

                                I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                                M Offline
                                M Offline
                                Michael A Cochran
                                wrote on last edited by
                                #35

                                In my mind, it was because of FORTRAN. Back in the day, we didn't have all that many languages to choose from and most of us wrote in 360 assembler, FORTRAN, or COBOL. As others have said, while FORTRAN did have typing, variables starting with i-n were defaulted to integers so we just used i - followed by j, k, l in nested loops - for simplicity. We also used foo, foobar, and jane for "temp" variables. foo and foobar were common for IBM programmers and jane was common in DEC code.

                                1 Reply Last reply
                                0
                                • H H Brydon

                                  Look at any mathematics text that is older than computers. You will find i, j, k, m, n rampant as indexes for just about any formula you can find. Also, x, y, z are common variables and A, B, C are commonly used as constants.

                                  -- Harvey

                                  E Offline
                                  E Offline
                                  englebart
                                  wrote on last edited by
                                  #36

                                  I second the math heritage. Remember the Capital Sigma sum sign like you see in Excel now? http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation[^] PI is used for products. http://en.wikipedia.org/wiki/Multiplication#Capital_Pi_notation[^]

                                  1 Reply Last reply
                                  0
                                  • T tumbledDown2earth

                                    I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                                    C Offline
                                    C Offline
                                    Cj Welborn
                                    wrote on last edited by
                                    #37

                                    I've never used fortran, I always thought of 'i' as an unnamed integer. A throw-away variable.

                                    1 Reply Last reply
                                    0
                                    • T tumbledDown2earth

                                      I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?

                                      A Offline
                                      A Offline
                                      Antonino Porcino
                                      wrote on last edited by
                                      #38

                                      now that you made me think of it, I realized of my habit of using "t" instead of "i" as my favorite looping variable. It's because I learned of FOR loops back in 1984 when typing BASIC programs on my Commodore VIC20. The user manual had several sound-effects example listings, mostly composed of a FOR T=something statement, where T stayed (I guess) for time. I typed many of them and eventually got the habit of the "t" variable. Effects were something like this:

                                      10 REM LUNAR LANDING EFFECT
                                      15 POKE 36878,15
                                      20 FOR T=200 TO 120 STEP -1
                                      30 POKE 36876,T
                                      40 FOR I=1 TO 100:NEXT I
                                      50 NEXT T

                                      (for the curious ones, 368678 was for volume "up" and 36876 for playing tone).

                                      1 Reply Last reply
                                      0
                                      • P PIEBALDconsult

                                        But "loop" is a verb. :~

                                        R Offline
                                        R Offline
                                        R Giskard Reventlov
                                        wrote on last edited by
                                        #39

                                        No, it's a word (noun and verb) that perfectly describes the intention of the code. I try to use as much 'real' English rather than silly tokens in code: makes the intention clear and the code eminently more readable.

                                        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

                                        S 1 Reply Last reply
                                        0
                                        • G greldak

                                          There were but they were implicit. Any variable name beginning with a letter between (and including) the first two letters of INteger was an integer, any other variable was a real.

                                          D Offline
                                          D Offline
                                          dg6yhw11
                                          wrote on last edited by
                                          #40

                                          Fascinating! I know and still use that convention but had no idea what that particular set of letters was chosen until now. Thanks. Murray

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups