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.
  • OriginalGriffO OriginalGriff

    It's also from FORTRAN for me, but we used just "i" rather than "index" partly because it saved time and space. We didn't have IDE's in those days, but punched cards (or paper tape) and is was a lot quicker to type a single character variable name on a punched card than a longer one. Saved waste as well if you mistyped "index" as "inedx" you had to chuck the card and type a new one. With paper tape each character occupied 1/10th inch of tape, so "index" used 5 times the paper each time you typed it. With a long subroutine, that could get significant and make the roll a lot bigger (and heavier) and harder to roll back up again when it spooled off the end of the reader... We only had 6 character variable names anyway... :laugh:

    The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

    B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #15

    Oi vey, us oldies that have worked with paper tape. I've never used it in programming, but way back, when I was in the SA Air Force, I used to man a station that relayed HF radio data from Antarctica to the SA weather bureau. My main comms with down south was a teletype machine at 50 baud after error correction through a (I think Siemens) Elmux machine. If the comms were bad and the data link failed, they'd send the weather data straight to me, to capture on paper tape and later relay to the weather people.

    1 Reply Last reply
    0
    • J Jacquers

      As someone already stated, I think it's i for iterator / index. But it also makes it easy to accidentally place a 1 in there e.g. dataset.Tables[1] and not spot a mistake. Sometimes I'll use r and c if iterating through rows and columns e.g. dataset.tables[0].rows[r][c]

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #16

      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?

      J D 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?

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

        I tend to use Index instead of i (I definitely like verbose identifiers). And when I need several indexes, like in nested loops, I naturally call them Jndex, Kndex, Lndex... (not kidding). I have not yet come to the point that I use Number and Mumber for counts.

        M 1 Reply Last reply
        0
        • R Rosenne

          AFAIK it started with the first FORTRAN - there were no type declarations then. See https://en.wikipedia.org/wiki/Fortran#FORTRAN[^]

          G Offline
          G Offline
          greldak
          wrote on last edited by
          #18

          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 1 Reply Last reply
          0
          • Y YDaoust

            I tend to use Index instead of i (I definitely like verbose identifiers). And when I need several indexes, like in nested loops, I naturally call them Jndex, Kndex, Lndex... (not kidding). I have not yet come to the point that I use Number and Mumber for counts.

            M Offline
            M Offline
            Matthew Bache
            wrote on last edited by
            #19

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

            Matt

            Y R 2 Replies 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?

              J Offline
              J Offline
              Jacquers
              wrote on last edited by
              #20

              It could happen during testing, but I agree that using the table name is better.

              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?

                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
                    • Y YDaoust

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

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

                      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
                      • P PIEBALDconsult

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

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

                        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
                        • 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
                                    • 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
                                      #32

                                      Why not just skip to "spa"

                                      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
                                        #33

                                        same thoughts

                                        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
                                          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