Thread: functions passing values

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    17

    Exclamation functions passing values

    hello guys,
    here i've doubt.here in this program just i called one function and displayed the values.but i'm not returing any value ,but i'm getting one value .please tell me why it's comming ?


    max(int ,int);
    main()
    {
    int i=10,j=5,k=0;
    k=max(i++,++j);
    printf("%d %d %d \n",i,j,k);
    }
    max(int i,int j)
    {
    printf("%d %d\n",i,j);
    }
    srinu

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Try declaring your function as void max(int, int);

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Why do you think it returned a value? It didn't. When you assign a variable like this, the behavior is undefined. The avoid this, add the keyword "void" before the function. If no keyword is present, the default is "int"! But besides that, it just looks sloppy to leave it blank like that.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    I think there should be an error message.
    -

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. Replies: 2
    Last Post: 07-03-2008, 11:31 AM
  3. Help Understanding Passing Arrays To Functions
    By jrahhali in forum C++ Programming
    Replies: 7
    Last Post: 04-10-2004, 02:57 PM
  4. passing structures to functions
    By AmazingRando in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2003, 11:22 AM
  5. Replies: 1
    Last Post: 01-20-2002, 11:50 AM