Why is there a bug?

This is a discussion on Why is there a bug? within the C Programming forums, part of the General Programming Boards category; Hi all, I get an error message when I run this code, can anyone tell me why? Have printed the ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    10

    Why is there a bug?

    Hi all, I get an error message when I run this code, can anyone tell me why? Have printed the error messages at the bottom

    Code:
    main()
    {
      double x;
      double y;
      scanf("%f", &x);
      scanf("%f", &y);
      
      printf("f(x,y)=%f", f(x, y));
      return 0;
    }
    
    double f(double dumx, double dumy)
    {
      double result; 
     result = (-(3.0*dumy)-(dumx*dumx)+(dumx/3.0)*(1.0/3.0));
    return result;
    }
    warning: type mismatch with previous implicit declaration
    warning: previous implicit declaration of `f'
    warning: `f' was previously implicitly declared to return `int

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    have you prototyped f() ?

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    10
    Thanks for the reply, have changed it to this but now when I run it, it will only let me make one input and always returns a value of 0. Does it need a big overhaul?

    Code:
    double f(double dumx, double dumy);
    
    main()
    {
      double x;
      double y;
      scanf("%f", &y);
      scanf("&f", &x);
      printf("f(x,y)=%f", f(x, y));
      return 0;
    }
    
    double f(double dumx, double dumy)
    {
      double result; 
     result = (-(3.0*dumy)-(dumx*dumx)+(dumx/3.0)*(1.0/3.0));
    return result;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Zooming Algorithm Bug
    By stuffy_boiz in forum C Programming
    Replies: 2
    Last Post: 01-19-2009, 01:34 AM
  2. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 02:47 PM
  3. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 12:56 PM
  4. Another link from Microsoft about bug in fread
    By vart in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-06-2008, 11:56 AM
  5. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 07:52 AM

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