473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

hello anyone...

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

Thankx......

Nov 14 '05 #1
14 23385
digital <di*******@fromru.com> 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 (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Ice cream sales somehow cause drownings: both happen in summer."
- Antti Voipio & Arto Wikla
Nov 14 '05 #2
"digital" <di*******@fromru.com> wrote in message
news:9c******************************@localhost.ta 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
Nov 14 '05 #3
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
Nov 14 '05 #4
"digital" <di*******@fromru.com> wrote in message news:<9c******************************@localhost.t 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.
Nov 14 '05 #5
lallous <la*****@lgwm.org> 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.
Nov 14 '05 #6
Christopher Benson-Manica wrote:
lallous <la*****@lgwm.org> 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.
Nov 14 '05 #7
Fred Bloggs wrote:
"digital" <di*******@fromru.com> wrote in message news:<9c******************************@localhost.t 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.
Nov 14 '05 #8
August Derleth wrote:

Christopher Benson-Manica wrote:
lallous <la*****@lgwm.org> 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
Nov 14 '05 #9
pete wrote:

August Derleth wrote:

Christopher Benson-Manica wrote:
lallous <la*****@lgwm.org> 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
Nov 14 '05 #10
"digital" <di*******@fromru.com> 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.
Nov 14 '05 #11
pete <pf*****@mindspring.com> wrote in message news:<40**********@mindspring.com>...
pete wrote:

August Derleth wrote:

Christopher Benson-Manica wrote:
> lallous <la*****@lgwm.org> 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
Nov 14 '05 #12
lallous wrote:

pete <pf*****@mindspring.com> wrote in message news:<40**********@mindspring.com>...
pete wrote:

August Derleth wrote:
>
> Christopher Benson-Manica wrote:
> > lallous <la*****@lgwm.org> 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
Nov 14 '05 #13
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.

Nov 14 '05 #14
August Derleth <se*@sig.now> wrote in message news:<js*****************@fe02.usenetserver.com>.. .
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.
Nov 14 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: m.j | last post by:
Hi, How to convert this pascal(delphi) function into java? The function is used in a algorithm. The trouble is that java don't have any unsigned 32bit type. What the trick, when you cannot...
19
by: Karl Scalet | last post by:
Hi, quite often there is a need to just print out the items of a list. that would be nice, except prt() does not exist, and print is a statement not a function, hence cannot replace prt as...
2
by: Mich | last post by:
I'm going crazy trying to convert an Access Function to SQL. From what I've read, it has to be done as a stored procedure. I'm trying to take a field that is "minutes.seconds" and convert it to...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: Daniel Nichols | last post by:
I've noticed that in a C module (.c, .h file combination) that if you create a function's definition before it is used in other functions than a declaration is not necessary. I believe if the...
26
by: Adam Warner | last post by:
Hello all, I'm very new to C but I have a number of years of Common Lisp programming experience. I'm trying to figure out ways of translating higher order concepts such as closures into C. The...
82
by: zardoz | last post by:
I've got this problem: unsigned long long lTemp; char cLargeNum="1324567890"; sscanf(clargeNum,"%llu",&lTemp); which under Win32 isn't working*. My program needs to compile under posix so...
4
by: cantatahost | last post by:
Hello, Likely this has been asked before... We have a library (in DLL form) that we distribute. The interface to the library is all C, but within the library it uses C++ in many places. ...
9
by: serge | last post by:
/* Subject: How to build a procedure that returns different numbers of columns as a result based on a parameter. You can copy/paste this whole post in SQL Query Analyzer or Management Studio...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.