functions passing values

This is a discussion on functions passing values within the C++ Programming forums, part of the General Programming Boards category; hello guys, here i've doubt.here in this program just i called one function and displayed the values.but i'm not returing ...

  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,700
    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:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(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, 10:50 AM

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