two dimensional array

This is a discussion on two dimensional array within the C Programming forums, part of the General Programming Boards category; i am writing a simple function that accepts an int and a 2d array. the function looks for the first ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    7

    two dimensional array

    i am writing a simple function that accepts an int and a 2d array. the function looks for the first row that has only zeros and prints the index of that row. if theres no row of zeros theres is no output. this is what i came up with. also. i am getting an error 'incompatible implicit declaration of built-in function ‘printf’ when i try to complie. any help would be apprciated. i am not even sure this is a correct way to achieve this goal.
    Code:
    void allZero (int n, int a[n][n]) {
      
          
    int sum = 0;
    int i,j,x;
     
    for(i=0;i<n;i++)
      {   
        if (a[i][0] == 0)
         {
         x = i; 
          for(j=0;j<n;j++)
           {
            sum += a[i][j];
     
         }
         }
      else
      { if(a[i][0] ==0)
     return;
      }   
    
    if (sum == 0)
    {
     printf("%d",x);
    }
    else
    { 
      if (!sum==0)  
    {
    
      return;
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    For your specific warning message, you should put this line at the top of your file
    Code:
    #include <stdio.h>
    For any subsequent problems you have, post your complete code (including "main" function) and any other warning/error messages or other logic problems you're having.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. two dimensional array
    By leisiminger in forum C Programming
    Replies: 12
    Last Post: 03-09-2008, 11:53 PM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM
  4. Replies: 5
    Last Post: 11-20-2001, 11:48 AM

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