IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Declarations and Initializations - Discussion

@ : Home > C Programming > Declarations and Initializations > General Questions - Discussion

Read more:

"I never see what has been done; I only see what remains to be done."
- Marie Curie
9. 

Identify which of the following are declarations
1 : extern int x;
2 : float square ( float x ) { ... }
3 : double pow(double, double);

[A]. 1[B]. 2
[C]. 1 and 3[D]. 3

Answer: Option A

Explanation:

extern int x; - is an external variable declaration.

double pow(double, double); - is a function prototype declaration.

Therefore, 1 and 3 are declarations. 2 is definition.


Haritha said: (Sat, Aug 28, 2010 03:33:10 PM)    
 
float square ( float x ) { ... }

Why it is not a declaration?

Sundar said: (Sun, Aug 29, 2010 02:14:11 AM)    
 
Hi Haritha,

It is the actual definition for the function 'square', which may or may not be declared previously.

Swathi Bhat said: (Mon, Feb 14, 2011 09:37:45 AM)    
 
What does double pow mean?

Sundar said: (Sat, Feb 26, 2011 04:47:05 AM)    
 
@Swathi Bhat

double pow(double, double);

It is a function prototype declaration. It should be defined somewhere in the program module. It denotes the following

1. Function name is 'pow'
2. It should called with 2 arguments of type 'double'
3. It will return a double value as result.

If you want to call the function then use the following method:

double Result;
Result = pow(5, 4);

Hope you can understand this. Have a nice day!

Aishu said: (Mon, May 30, 2011 11:39:09 PM)    
 
Can you tel me what is the difference between declaration and definition and state some examples?

Surya said: (Sun, Jun 12, 2011 10:52:46 AM)    
 
Nice explanation Sundar.

Jaz said: (Mon, Aug 1, 2011 09:07:08 PM)    
 
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.

Vivek Patel said: (Mon, Sep 19, 2011 08:25:44 PM)    
 
Thanks to all for a good answers.

Ramarao Mundru said: (Wed, Nov 9, 2011 07:41:43 AM)    
 
Hi,

file f1.c
extern int a;//declaration because it doesn't allocate memory for a variable,it has allocated memory somewhere else in the program
file f2.c
int a;// it is definition because here it is getting memory

a=3;//it is assigment

Naveen Goud said: (Wed, Jan 4, 2012 03:57:37 PM)    
 
@aishu

A declaration is just writing a type of variable or function.

a definition is simply assigning a values to that particular variable or function.

Write your comments here:
Name *:     Email:


© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!