help! i need somebody help! not just any...help!!!

This is a discussion on help! i need somebody help! not just any...help!!! within the C Programming forums, part of the General Programming Boards category; hello all, I need help with this code, the compiler says it has conflicting types of functions (scan_b for example)... ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    29

    Question help! i need somebody help! not just any...help!!!

    hello all,
    I need help with this code,
    the compiler says it has conflicting types of functions (scan_b for example)...
    thanks again,
    Livnat.

    Code:
    #include <stdio.h>
    #include <math.h>
    
    void scan_b(double  , int , int );
    void print_b(double  , int  , int );
    void norm_b(double , int , int );
    double std_b(double , int , int );
    double avg_b(double , int , int );
    
    
    
    int main()
    {
    int k,l;
    double c[100][100];
    printf("please enter the number of rows and columns");
    scanf("&#37;d%d" , &k, &l);
    scan_b(c[100][100] ,k,l);
    print_b(c[100][100] ,k,l);
    norm_b( c[100][100] ,  k,  l);
    printf ("the Standard deviation is: %lf" ,std_b( c[100][100] , k,  l));
    printf ("the mean value is: %lf" ,avg_b( c[100][100] ,  k,  l));
    return 0;
    }
    
    
    
    void scan_b(double b[100][100] , int i, int j)
    {
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   scanf("%d" , &(b[m][n]));
    }
    
    double avg_b(double b[100][100] , int i, int j)
    {
    int m,n;
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   printf("%d" , &(b[m][n]));
    }
    
    void norm_b(double b[100][100] , int i, int j)
    {
    double sum=0,avg, avg2;
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    
    avg=sum/(i*j);
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   b[m][n]=b[m][n]-avg;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n]*b[m][n];
    avg2=sum/(i*j);
    
    for (m=0 ; m<i ; m++)
    double std_b(double b[100][100] , int i, int j);        for (n=0 ; n<j ; n++)
                   b[m][n]=(b[m][n])/sqrt(avg2);
    }
    
    int avg_b(double b[100][100] , int i, int j)
    {
    double sum=0,avg, avg2;
    int m,n;
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    
    avg=sum/(i*j);
    return avg;
    }
    
    double std_b(double b[100][100] , int i, int j);
    {
    double avg,avg2,sum,std;
    int m,n;
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n]*b[m][n];
    
    avg2=sum/(i*j);
    
    for (m=0 ; m<i ; m++)
           for (n=0 ; n<j ; n++)
                   sum+=b[m][n];
    avg=sum/(i*j);
    
    std=sqrt(avg2-pow(avg,2));
    return std;
    }
    Last edited by Livnat; 07-13-2008 at 02:19 PM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    scan_b(c[100][100] ,k,l);
    print_b(c[100][100] ,k,l);
    Because doing like that passes the element at 100, 100 (which does not exist, btw) to a function which expects an array.
    And it's bad practice to strip the names of the arguments from the prototypes.
    For example:
    void scan_b(double , int , int );
    Is better as:
    void scan_b(double array, int rows, int columns);

    EDIT:
    Plus your functions and prototypes does not match.
    void scan_b(double , int , int );
    void scan_b(double[100][100] , int , int );
    Make them match!
    Last edited by Elysia; 07-13-2008 at 02:37 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,852
    Didn't we just do this?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

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