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?

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

    I now use 'loop' as it is easier to read the code though I did use i for many years just because it was the convention.

    "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

    P 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
      AspDotNetDev
      wrote on last edited by
      #9

      We programmers are a self-centered bunch. It's never about the other person, it's always "I I I" this, "I I I" that. jk, jk. lol. Hmmm... I suppose the letters in preference would have to be: ijklo. An expanding counter-clockwise spiral starting with "i"! From this, we can ascertain the correct letters to use for each new level of loop nesting: ijklouhmpygntfbrdvescwaxqz. Any other order is incorrect.

      Thou mewling ill-breeding pignut!

      L 1 Reply Last reply
      0
      • R R Giskard Reventlov

        I now use 'loop' as it is easier to read the code though I did use i for many years just because it was the convention.

        "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

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #10

        But "loop" is a verb. :~

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

          H Offline
          H Offline
          H Brydon
          wrote on last edited by
          #11

          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 1 Reply Last reply
          0
          • A Amarnath S

            Yes - for me it is a Fortran language practice. In Fortran IV, any variable starting with I, J, K, L, M, N is an integer (case-insensitive), whereas a variable starting with any other letter is a float. This continued for me, through C, Java, C++, C#.

            R Offline
            R Offline
            Rosenne
            wrote on last edited by
            #12

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

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

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

              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 1 Reply Last reply
              0
              • 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
                #14

                And, mainly, all the CS textbooks use i and j for loops.

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