Like Tree1Likes
  • 1 Post By Nominal Animal

Array problem

This is a discussion on Array problem within the C Programming forums, part of the General Programming Boards category; Write the definition of a function printArray , which has two parameters. The first parameter is an array of int ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    11

    Array problem

    Write the definition of a function printArray , which has two parameters. The first parameter is an array of int s and the second is an int , the number of elements in the array. The function does not return a value. The function prints out each element of the array, on a line by itself, in the order the elements appear in the array, and does not print anything else.
    i have:
    Code:
    void printArray(int a[], int n)
    {
    for (i=0; i < n ; i++)
    printf("%d\n",a[i]);
    }
    i have to turn this into an online quiz kinda thing but it's telling me its incorrect and i need to add something prior to the for.

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    854
    Quote Originally Posted by Ninjabelly View Post
    it's telling me its incorrect and i need to add something prior to the for.
    What is i? Perhaps you should declare it to the compiler, too, before using it.
    Ninjabelly likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using an array, problem
    By .C-Man. in forum C++ Programming
    Replies: 24
    Last Post: 03-10-2011, 06:43 AM
  2. problem initializing a double array for large array
    By gkkmath in forum C Programming
    Replies: 4
    Last Post: 08-25-2010, 08:26 PM
  3. Problem converting from char array to int array.
    By TheUmer in forum C Programming
    Replies: 11
    Last Post: 03-26-2010, 11:48 AM
  4. simple array of char array problem
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 09-10-2006, 12:04 PM
  5. Possible array problem.
    By fatdunky in forum C Programming
    Replies: 1
    Last Post: 12-07-2005, 12:59 AM

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