C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 11)
11.
When we mention the prototype of a function?
Defining
Declaring
Prototyping
Calling
Answer: Option
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.

Discussion:
46 comments Page 4 of 5.

Sundar said:   1 decade ago
@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:   1 decade ago
Thank you for your feedback @sundar.

Anuj Kumar said:   1 decade ago
What is the diffetence between function declaration and prototyping ?

Lodu said:   1 decade ago
Prototype means we specifies the interface of that declared function. And we will use that function for coherent task.

Shivaji said:   1 decade ago
#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

Aditya said:   1 decade ago
If possible say what is "prototype" in explanation.

Kavitha said:   1 decade ago
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:   1 decade ago
What about initializing and defining. ?

Rajalakshmi said:   1 decade ago
What is difference between definition and declaration?

Swapnil said:   1 decade ago
Declaration is the process of declaring the variable with some special name and its data-type,scope,memory storage etc. and definition is actually assining some value to that variable.

In case of function declaration is defining its prototype and declaration is code where we specify what the function actually does.

Examples:

case 1) variable

Variable Declaration:
int a,b[10];

Variable Definition:
a=1, b={1,2,3,....};


Function Declaration:
void display();

Function Definition:

void display()
{
printf("......");
}


Post your comments here:

Your comments will be displayed after verification.