the different between function and procedure for C/C++ and Pascal

Discussion in 'C Programming' started by Joona I Palaste, Jan 19, 2004.

  1. digital <> scribbled the following:
    > hello anyone...
    >
    > pls explain me , how different between function and procedure for C/C++ and Pascal.


    For C and C++:
    There is no such thing as "procedure".
    For Pascal:
    Ask at comp.lang.pascal.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Ice cream sales somehow cause drownings: both happen in summer."
    - Antti Voipio & Arto Wikla
     
    Joona I Palaste, Jan 19, 2004
    #1
    1. Advertising

  2. Joona I Palaste

    digital Guest

    hello anyone...

    pls explain me , how different between function and procedure for C/C++ and Pascal.

    Thankx......
     
    digital, Jan 19, 2004
    #2
    1. Advertising

  3. Joona I Palaste

    lallous Guest

    "digital" <> wrote in message
    news:...
    > hello anyone...
    >
    > pls explain me , how different between function and procedure for C/C++

    and Pascal.
    >
    > Thankx......
    >

    Hello,

    In pascal, the difference between procedure and function is that:
    procedure does not have a return value and function have a return value.
    So there is no real difference, and all pascal procedures can be written as
    functions, and you disregard the return type/value.

    In C, all routines, procedures, functions are named a 'function'.

    To map from C function to pascal procedure:
    procedure myproc(x: integer); { pascal code }
    void myproc(int x); /* C code */

    The 'void' as a return type is used to denote that function has no return
    type.

    --
    Elias
     
    lallous, Jan 19, 2004
    #3
  4. digital wrote:

    > hello anyone...
    >
    > pls explain me , how different between function and procedure for C/C++ and Pascal.


    There is no such thing as C/C++, and C has only functions.
    Pascal conventionally calls functions that do not return values (that is,
    that are executed solely for their side-effects) 'procedures.' In C, they
    are just functions with a return type of void.

    --
    Martin Ambuhl
     
    Martin Ambuhl, Jan 19, 2004
    #4
  5. Joona I Palaste

    Fred Bloggs Guest

    "digital" <> wrote in message news:<>...
    > hello anyone...
    >
    > pls explain me , how different between function and procedure for C/C++ and Pascal.


    The difference is that c++ and pascal are offtopic here, and C doesn't
    have procedures.
     
    Fred Bloggs, Jan 19, 2004
    #5
  6. lallous <> spoke thus:

    > The 'void' as a return type is used to denote that function has no return
    > type.


    FMI, is this statement identical to "... function does not return
    anything?"

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Jan 19, 2004
    #6
  7. Christopher Benson-Manica wrote:
    > lallous <> spoke thus:
    >
    >
    >>The 'void' as a return type is used to denote that function has no return
    >>type.

    >
    >
    > FMI, is this statement identical to "... function does not return
    > anything?"
    >


    It's a clumsy and possibly pedantically incorrect way of saying it, but
    I think that's what lallous means.

    (Perhaps lallous could have said `does not return an object of a usable
    type', since trying to inspect or modify an object of void type is not
    allowed in C. But that's, again, rather clumsy compared with `does not
    return any value.', and could be technically incorrect.)

    --
    My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
    Note: Rot13 and convert spelled-out numbers to numerical equivalents.
     
    August Derleth, Jan 19, 2004
    #7
  8. Fred Bloggs wrote:

    > "digital" <> wrote in message news:<>...
    >
    >>hello anyone...
    >>
    >> pls explain me , how different between function and procedure for C/C++ and Pascal.

    >
    >
    > The difference is that c++ and pascal are offtopic here, and C doesn't
    > have procedures.


    C++ and Pascal are offtopic, but discussing the differences between them
    and C isn't verboten as long as everyone knows that comp.lang.c isn't
    guaranteed to know anything about anything other than standard C. (And
    even /that/ isn't Guaranteed, but we do try. :) )

    Anyway, in Pascal a procedure is a function that does not return a value.

    In C, nothing is called a procedure but functions are allowed to not
    return anything. This is indicated by giving the function a return type
    of void.

    C++ is largely similar to C in this respect.

    --
    My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
    Note: Rot13 and convert spelled-out numbers to numerical equivalents.
     
    August Derleth, Jan 19, 2004
    #8
  9. Joona I Palaste

    pete Guest

    August Derleth wrote:
    >
    > Christopher Benson-Manica wrote:
    > > lallous <> spoke thus:
    > >
    > >
    > >>The 'void' as a return type is used to denote that
    > >>function has no return type.

    > >
    > >
    > > FMI, is this statement identical to "... function does not return
    > > anything?"
    > >

    >
    > It's a clumsy and possibly pedantically incorrect
    > way of saying it,


    I think that's a good way of saying it.

    > but I think that's what lallous means.
    >
    > (Perhaps lallous could have said `does not return an object of a
    > usable type',
    > since trying to inspect or modify an object of void type is not
    > allowed in C. But that's, again, rather clumsy compared with `does not
    > return any value.', and could be technically incorrect.)


    I think that's worse.
    The return value of a function is an rvalue, not an object.

    --
    pete
     
    pete, Jan 19, 2004
    #9
  10. Joona I Palaste

    pete Guest

    pete wrote:
    >
    > August Derleth wrote:
    > >
    > > Christopher Benson-Manica wrote:
    > > > lallous <> spoke thus:
    > > >
    > > >
    > > >>The 'void' as a return type is used to denote that
    > > >>function has no return type.
    > > >
    > > >
    > > > FMI, is this statement identical to "... function does not return
    > > > anything?"
    > > >

    > >
    > > It's a clumsy and possibly pedantically incorrect
    > > way of saying it,

    >
    > I think that's a good way of saying it.


    Refering to "... function does not return anything"

    > > but I think that's what lallous means.
    > >
    > > (Perhaps lallous could have said `does not return an object of a
    > > usable type',
    > > since trying to inspect or modify an object of void type is not
    > > allowed in C. But that's, again, rather clumsy compared with `does not
    > > return any value.', and could be technically incorrect.)

    >
    > I think that's worse.
    > The return value of a function is an rvalue, not an object.
    >
    > --
    > pete


    --
    pete
     
    pete, Jan 19, 2004
    #10
  11. Joona I Palaste

    Derk Gwen Guest

    "digital" <> wrote:
    # hello anyone...
    #
    # pls explain me , how different between function and procedure for C/C++ and Pascal.

    A procedure is void function. A function is nonvoid function.
    Instead of assigning to the function name, assign to a local variable with
    the same type, say result, and add a return of that at the and

    procedure P; begin void P() {
    ... ...
    end }

    function F: T; begin T F() {T result;
    ... ...
    F := x; result := X;
    ... ...
    end; return result;}

    --
    Derk Gwen http://derkgwen.250free.com/html/index.html
    She broke your heart and inadvertendently drove men to deviant lifestyles.
     
    Derk Gwen, Jan 19, 2004
    #11
  12. Joona I Palaste

    lallous Guest

    pete <> wrote in message news:<>...
    > pete wrote:
    > >
    > > August Derleth wrote:
    > > >
    > > > Christopher Benson-Manica wrote:
    > > > > lallous <> spoke thus:
    > > > >
    > > > >
    > > > >>The 'void' as a return type is used to denote that
    > > > >>function has no return type.
    > > > >
    > > > >
    > > > > FMI, is this statement identical to "... function does not return
    > > > > anything?"
    > > > >
    > > >
    > > > It's a clumsy and possibly pedantically incorrect
    > > > way of saying it,

    > >
    > > I think that's a good way of saying it.

    >
    > Refering to "... function does not return anything"
    >
    > > > but I think that's what lallous means.
    > > >
    > > > (Perhaps lallous could have said `does not return an object of a
    > > > usable type',
    > > > since trying to inspect or modify an object of void type is not
    > > > allowed in C. But that's, again, rather clumsy compared with `does not
    > > > return any value.', and could be technically incorrect.)

    > >
    > > I think that's worse.
    > > The return value of a function is an rvalue, not an object.
    > >
    > > --
    > > pete


    Hello,

    > > > >>The 'void' as a return type is used to denote that
    > > > >>function has no return type.
    > > > >
    > > > >
    > > > > FMI, is this statement identical to "... function does not return
    > > > > anything?"
    > > > >
    > > >
    > > > It's a clumsy and possibly pedantically incorrect
    > > > way of saying it,


    I would be glad to learn how to say it correctly in technical terms.

    Or simply, if said again (drawing from previous posts): "It does not
    return a usable value" ?

    --
    Elias
     
    lallous, Jan 20, 2004
    #12
  13. Joona I Palaste

    pete Guest

    lallous wrote:
    >
    > pete <> wrote in message news:<>...
    > > pete wrote:
    > > >
    > > > August Derleth wrote:
    > > > >
    > > > > Christopher Benson-Manica wrote:
    > > > > > lallous <> spoke thus:
    > > > > >
    > > > > >
    > > > > >>The 'void' as a return type is used to denote that
    > > > > >>function has no return type.
    > > > > >
    > > > > >
    > > > > > FMI, is this statement identical to "... function does not return
    > > > > > anything?"
    > > > > >
    > > > >
    > > > > It's a clumsy and possibly pedantically incorrect
    > > > > way of saying it,
    > > >
    > > > I think that's a good way of saying it.

    > >
    > > Refering to "... function does not return anything"
    > >
    > > > > but I think that's what lallous means.
    > > > >
    > > > > (Perhaps lallous could have said `does not return an object of a
    > > > > usable type',
    > > > > since trying to inspect or modify an object of void type is not
    > > > > allowed in C. But that's, again, rather clumsy compared with `does not
    > > > > return any value.', and could be technically incorrect.)
    > > >
    > > > I think that's worse.
    > > > The return value of a function is an rvalue, not an object.
    > > >
    > > > --
    > > > pete

    >
    > Hello,
    >
    > > > > >>The 'void' as a return type is used to denote that
    > > > > >>function has no return type.
    > > > > >
    > > > > >
    > > > > > FMI, is this statement identical to "... function does not return
    > > > > > anything?"
    > > > > >
    > > > >
    > > > > It's a clumsy and possibly pedantically incorrect
    > > > > way of saying it,

    >
    > I would be glad to learn how to say it correctly in technical terms.
    >
    > Or simply, if said again (drawing from previous posts): "It does not
    > return a usable value" ?


    The first way to say it that pops into my head is
    "it doesn't return anything."
    "It does not return a usable value", would be a subset
    of that statement. Returning a value, is done by writing
    the return value to someplace that the calling function
    will have access to read.
    A function with a void return type, doesn't have to do that.

    --
    pete
     
    pete, Jan 20, 2004
    #13
  14. digital wrote:

    > What is the difference between function and procedure for C/C++ and Pascal.


    Procedures are only possible in *imperative* computer programming
    languages like Fortran, Pascal, C, C++, etc.
    The *thread* of execution normally *proceeds* from one imperative
    (executable statement) to the next. Flow control "structures"
    such as conditionals, loops, switch, case, etc.
    may change the normal sequence of execution.
    Within the context of each imperative computer programming language,
    procedures which return a value are called functions:

    language returns value no return value
    -----------------------------------------------
    C/C++ function void function
    Fortran function subroutine
    Pascal function procedure

    Note that functions need not be procedures:

    int min(int i, int j) {
    return (i < j)? i: j;
    }

    and simply return the value of an expression.
    It is possible to write useful C programs
    without any imperatives at all -- no procedures!
    An *applicative* of "functional" programming language
    like lisp has no imperatives and, thus, *no* procedures.
     
    E. Robert Tisdale, Jan 20, 2004
    #14
  15. Joona I Palaste

    Fred Bloggs Guest

    August Derleth <> wrote in message news:<jsROb.9190$>...
    > C++ and Pascal are offtopic, but discussing the differences between them
    > and C isn't verboten


    comp.lang.c is for the discussion of C as pertains to the relevant standards.
     
    Fred Bloggs, Jan 20, 2004
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Gordon-Smith

    Calling Pascal from C++ and Vice Versa

    Chris Gordon-Smith, Jan 17, 2004, in forum: C++
    Replies:
    4
    Views:
    3,029
    EventHelix.com
    Jan 18, 2004
  2. Hans-Marc Olsen
    Replies:
    4
    Views:
    3,086
    Jacek Dziedzic
    Nov 19, 2004
  3. Mike P
    Replies:
    0
    Views:
    3,374
    Mike P
    Jun 19, 2006
  4. AlexWare
    Replies:
    2
    Views:
    788
    Paul Uiterlinden
    Oct 23, 2009
  5. Don Otknow
    Replies:
    2
    Views:
    2,938
    westocl
    Mar 8, 2011
Loading...

Share This Page