Thread: Array Question problem

  1. #1
    Registered User
    Join Date
    May 2011
    Location
    Ireland
    Posts
    13

    Question Array Question problem

    Code:
    Im given two arrays
    int [] scores1 = {2,5,8,10}
    int [] score2 = {5,6,8,12}
    
    and asked to multiply 1st element of scores 1 by last element  of scores2..
    
    would i use a for statement for this??
    
    like: for (int i = 0

  2. #2
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Since you know the array lengths in advance:

    Code:
    int result = score1[0] * score2[3];
    Otherwise:

    Code:
    int result = score1[0] * score2[score2.Length - 1];
    Have a read of this Arrays Tutorial (C#) to better understand what arrays are and how the work.

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Ireland
    Posts
    13
    cheers..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem initializing a double array for large array
    By gkkmath in forum C Programming
    Replies: 4
    Last Post: 08-25-2010, 08:26 PM
  2. Problem converting from char array to int array.
    By TheUmer in forum C Programming
    Replies: 11
    Last Post: 03-26-2010, 11:48 AM
  3. 2 Dimensional array question/problem
    By lanchfn21 in forum C++ Programming
    Replies: 2
    Last Post: 01-23-2003, 11:15 AM
  4. problem with my array question
    By datainjector in forum C Programming
    Replies: 6
    Last Post: 08-01-2002, 02:39 PM
  5. Question on an array practice problem
    By Vanished in forum C Programming
    Replies: 1
    Last Post: 01-22-2002, 07:12 PM