What is the difference between declaration and definition?
Answers were Sorted based on User's Feedback
Answer / adarsh gupta
Function declaration -
*Requires semicolon,
*Contains actual parameters,
*Tells about the type of value returned by function,
*This unit can't be invoked from other parts of program.
Function definition-
*Don't require semi coloun,
*Contans the main part(main ligic) of the program,
*Can be invoked from other parts of program,
*Uses formal parameters.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / alok
defination=(declration+space reservation)
int a; -------------Declaration
a=20; ------------- Defination
For Function
int alok(int a,int b); ---------------Declaration
int a=alok(5,10) ---------------Function call
int alok(int a,int b) Function Defination Logic is here
{
int c=a+b;
return(c);
}
// Alok contact number 9993032168,9650549204
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / soumyajit
During declaration we just specify the type and no memory
is allocated to the variable. But during the definition an
initial value is assigned and memory is allocated to the
variable.
or we can also say,
Declaration means just telling to complier about variable
or function but definition means actually allocating memory
for variable.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / durga devi.s
variable must be declared and defined before used in the program
variable declaration:
1. tells the compiler what is the name of the variable.
2. specifies what type of data values the variable can hold.
variable definition
1. reserves the memory for the declared variable and store
some value is called garbage value.
-> variable declaration and variable definition done at the
same time.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / arun
if declaration is only informing compiler that the return
data type then the following should not work
int a;
int b;
b=a;
The above code will work even if a has no memory assigned
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / palsaniya sadikhasan, meta.
Declaration of variable and function means to create memory
for a variable or function.
e.g. int a;
will create a memory 2 byte in main memory.
definition means to assign a value to the particular
variable that are used in function.
| Is This Answer Correct ? | 4 Yes | 6 No |
Declaration means,we just inform to compiler return
type,funtion name and argument list of funtion that later
use in program.Definition define the operation of that
funtion.
| Is This Answer Correct ? | 15 Yes | 20 No |
Answer / amiya
defination=(declration+space reservation)
int a; -------------Declaration
a=20; ------------- Defination
For Function
int amiya(int a,int b); ---------------Declaration
int a=amiya(5,10) ---------------Function call
int amiya(int a,int b) Function Defination Logic is here
{
int c=a+b;
return(c);
}
| Is This Answer Correct ? | 24 Yes | 33 No |
Answer / sandhya shetty
Declaration means only declaring a function or a variable
with its return type or datatype respectively.
Definition means assiging values to variable or procedure
to be performed by a function.
| Is This Answer Correct ? | 21 Yes | 41 No |
This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.
why the memory allocated with new cant be freed using free()
What is conditional Compilation?
should we use linear search or binary search if elements are placed in random order or mixed?in both cases? i need a little bit detail ans?thnks
wht is major diff b/w c and c++?
what is difference between objects and function
Prepare me a program for the animation of train
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
What is function overloading?,describe it with the example.
A file pointer always contains the __________ of the file
why to use template classes in c++?
What is methods in oop?