Thread: ok Im an idiot,but please answer these...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    11

    ok Im an idiot,but please answer these...

    1. what is a statement ?give an example pls.

    2. what is a function? "

    3. what is a expression? "



    P.S. I already know what variables are, but these three makes confuses me. Im interested in the real concept of these,examples would also help.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    o.k., but first tell me what you think they mean.
    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;
    }

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    And if you need some hints, think about what they mean in everyday language (and in the case of functions, what does it mean in math?)

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by sean_mackrory
    And if you need some hints, think about
    This seems to be a recurring theme today.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Quzah, I'm disappointed in you. You should know by now that people not thinking for themselves is a recurring theme everyday. It also seems like every day that someone takes your advice as an invitation to remove themselves from the human gene pool. Though it's not a bad idea for some of them.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    11
    sorry never mind.

  7. #7
    Registered User joed's Avatar
    Join Date
    Mar 2004
    Posts
    59
    This program exits when "x" is greater than 5:

    Code:
    int main()
    {
        int x;
    
        for(x = 0; x < 10; x++)
            if(test(x))
                break;
    }
    
    int test(int x)
    {
        if(x > 5)
            return 1;
        else
            return 0;
    }
    "int x" is a declaration. Things like the "for", "break", etc are statements. Expressions are more mathematical, like "x > 5" or "x = 0". A function is a self-contained block of code which can be called as needed, and can return a result if desired. In this program "main()" and "test()" are functions.

    P.S. why say anything at all if you aren't going to answer the dude's question?

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    > 1. what is a statement ?
    A piece of code that performs an action.

    > 2. what is a function? "
    A named collection of statements.

    > 3. what is a expression? "
    A bunch of operators and operands that do stuff.
    My best code is written with the delete key.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > 3. what is a expression? "
    All these are expressions






    <runs and hides>
    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.

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    As Frank Barone says, the bathroom is the only room the house where a man can truly express himself. I'd be happy to share some of my expressions with you.

  11. #11
    Registered User
    Join Date
    Sep 2004
    Posts
    11
    Thanks to those who answered. I ask these seemingly easy questions basically because Im really having a hard time understanding them.Of course I have my own understanding of these things but it helps to compare to people who really know what theyre talking about.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  3. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 03:25 PM
  4. code help :)
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 02-28-2002, 01:12 PM
  5. Replies: 22
    Last Post: 11-08-2001, 11:01 PM