"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe."
- Albert Einstein
11.
When we mention the prototype of a function?
[A].
Defining
[B].
Declaring
[C].
Prototyping
[D].
Calling
Answer: Option B
Explanation:
A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function's name, argument types and return type.
While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.
If possible say what is "prototype" in explanation.
Srinu said:
(Sun, Sep 26, 2010 12:56:53 AM)
What is prototype?
Amar said:
(Wed, Oct 13, 2010 06:07:01 AM)
Prototype means we specifies the interface of that declared function. And we will use that function for coherent task.
Megha Tavrech said:
(Fri, Nov 26, 2010 12:15:44 PM)
Prototype means just declaring the function, not providing body?
I think now it is understandable.
Sundar said:
(Sun, Jan 2, 2011 07:12:57 AM)
Give me the definition for the declaring and the defining and also prototype.
Revathy said:
(Mon, Jan 3, 2011 06:31:41 AM)
int a;
is the declaration- it simply assigns the datatype for the variable
int a=10; is the definition- it assigns the value for the variable- the value given should match d datatype
Prathyusha said:
(Sat, Mar 5, 2011 03:26:31 AM)
#include<stdio.h>
int funcall(int,int);//function prototyping
void main()
{
int a,sum;
sum=funcall(10,20);
printf("sum is %d",sum);
}
int funcall(int a,int b)
{
int cal=a+b;
return cal;
}
Output: sum is 10
When compiler come across the statement: sum=funcall(10,20);
it wants to know wat type of value it will return.so at that time it will go and check whether function prototyping is given or not , to see the datatype of the parameter used by that function.
CORRECT ME IF I AM WRONG PLZ!...
Sundar said:
(Sat, Mar 5, 2011 06:58:16 AM)
@Prathyusha
This type of prototype declaration requires only in old compilers. (TurboC under 16-bit DOS OS).
But in modern compilers this function prototyping is not required.
GCC, VC++, C#, etc.
Prathyusha said:
(Sat, Mar 5, 2011 12:16:21 PM)
Thank you for your feedback @sundar.
Anuj Kumar said:
(Thu, Apr 7, 2011 03:47:07 PM)
What is the diffetence between function declaration and prototyping ?
Lodu said:
(Mon, Apr 18, 2011 05:21:37 AM)
Prototype means we specifies the interface of that declared function. And we will use that function for coherent task.
Shivaji said:
(Wed, Jun 8, 2011 02:20:22 PM)
#include<stdio.h>
int funcall(int,int);//function prototyping
void main()
{
int sum=0;
int a=10,b=30;
sum=funcall(a,b);
printf("\nsum is %d",sum);
}
int funcall(a,b) //function definition
{
int cal=a+b;
printf("\ncal=%d",cal);
return cal;
}
out put: 40
Sorry prathyusha ur output is wrong that is not 10, 30 is the anws.
We have not to declare a is must that is mandetory...
y b'case we already declaring function call dat is funcall(int,int)..
any how ur explaination is good...
Thank u mr.sundar
Tomson said:
(Fri, Sep 30, 2011 03:43:59 PM)
What is the difference between initializing and declaring?
Kavitha said:
(Wed, Oct 5, 2011 11:15:14 AM)
Hi tomson,
Declaration is
int a;
char b;
float c;
.....
Initialization is
a=10;
b='h';
c=1.2;
We can use both declaration and initialization at same time
int a=10;
char b='w';
......
I think so now u understand.
If you hav any other doubt ask me.
Gursimran said:
(Sat, Dec 17, 2011 04:48:09 PM)
What about initializing and defining. ?
Rajalakshmi said:
(Thu, Jan 5, 2012 12:37:03 PM)
What is difference between definition and declaration?