Array Question

This is a discussion on Array Question within the C++ Programming forums, part of the General Programming Boards category; An individual array element which is a simple data type can be passed as an argument to a function? is ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    68

    Array Question

    An individual array element which is a simple data type can be passed as an argument to a function? is this true or false? explain your answer please.

  2. #2
    Registered User
    Join Date
    Nov 2009
    Posts
    82
    True.

    int Foo(int i) return i;
    int A[3] = {13, 69, 7};
    cout << Foo(A[0]) << endl;
    Last edited by since; 12-01-2009 at 01:49 PM.

  3. #3
    Registered User DeadlyWarrior's Avatar
    Join Date
    Dec 2009
    Location
    Pakistan
    Posts
    5
    An array element can also be passed by storing that particular element located at that index into the varaiable of same data type as array have and then pass that variable as argument.

    int Array[5]={0,1,2,3,4};
    int variable = Array[1];

    now variable has a value "1" in it.
    So pass the "variable " as an argument in any function.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    True,

    Code:
    void display(const int data) {
      printf("%d", data)
    }
    
    int main() {
      int array[] = {1, 2, 3, 4};
      display(array[3]); // answer will be 4
     return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 07:07 PM
  2. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  4. array question?
    By correlcj in forum C++ Programming
    Replies: 1
    Last Post: 11-08-2002, 06:27 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21