• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #943
    admin
    Keymaster

      Although int i and int j as well int voter and int rank are all integer data type, there is a dimensional difference between first two (int i and int j) and last two (int voter and int rank).

      It should be because voter and rank are getting values based on two for loops involving i and j. So we can call voter and rank as two dimensional arrays. Although no where could I see voter and rank defined as arrays! It is int preferences that includes voter and rank:

      
      
      // preferences[j] is jth preference for voter i
      int preferences[MAX_VOTERS][MAX_CANDIDATES];

      Initially, when I tried to use printf (line 141), I did not expect two dimensional values (01,02,03…), given voter defined as int type (missed my attention that arrays too can be of int type).

      printf(“voter no.: %i”, voter);

      So while on first look, it appeared to me that i,j and voter, rank are synonymous, they are not.

      While int preferences by definition two dimensional, interesting to see how voter and rank too are getting transformed as two dimensional by application of for loops (involving i and j).

      Note: The reason I have posted is if anyone can correct or add to what I observed.


      Reply


      https://edstem.org/us/courses/176/discussion/2260175?comment=5163337[learn_press_profile]

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top