Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > the different between function and procedure for C/C++ and Pascal

Reply
Thread Tools

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

 
 
Joona I Palaste
Guest
Posts: n/a
 
      01-19-2004
digital <(E-Mail Removed)> 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 ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Ice cream sales somehow cause drownings: both happen in summer."
- Antti Voipio & Arto Wikla
 
Reply With Quote
 
 
 
 
digital
Guest
Posts: n/a
 
      01-19-2004
hello anyone...

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

Thankx......

 
Reply With Quote
 
 
 
 
lallous
Guest
Posts: n/a
 
      01-19-2004
"digital" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) lkaboutprogramming.com...
> 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


 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      01-19-2004
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
 
Reply With Quote
 
Fred Bloggs
Guest
Posts: n/a
 
      01-19-2004
"digital" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) alkaboutprogramming.com>...
> 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.
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      01-19-2004
lallous <(E-Mail Removed)> 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.
 
Reply With Quote
 
August Derleth
Guest
Posts: n/a
 
      01-19-2004
Christopher Benson-Manica wrote:
> lallous <(E-Mail Removed)> 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.


 
Reply With Quote
 
August Derleth
Guest
Posts: n/a
 
      01-19-2004
Fred Bloggs wrote:

> "digital" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) alkaboutprogramming.com>...
>
>>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.


 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      01-19-2004
August Derleth wrote:
>
> Christopher Benson-Manica wrote:
> > lallous <(E-Mail Removed)> 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
 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      01-19-2004
pete wrote:
>
> August Derleth wrote:
> >
> > Christopher Benson-Manica wrote:
> > > lallous <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIfference between function and procedure Don Otknow VHDL 2 03-08-2011 09:13 PM
procedure as argument in procedure AlexWare VHDL 2 10-23-2009 09:14 AM
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
what's the difference between the different the different GraphicConfigurations Flip Java 0 07-30-2004 03:50 PM
Calling Pascal from C++ and Vice Versa Chris Gordon-Smith C++ 4 01-18-2004 08:34 PM



Advertisments