|
INTERVIEW QUESTIONS
C
C BASICS
DETAILS
Question: What is the benefit of using #define to declare a constant ?
Answer: Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to maintain only the #define statement and not several instances of individual constants throughout your program.
For instance, if your program used the value of pi (approximately 3.14159) several times, you might want to declare a constant for pi as follows:
#define PI 3.14159
Using the #define method of declaring a constant is probably the most familiar way of declaring constants to traditional C programmers. Besides being the most common method of declaring constants, it also takes up the least memory.
Constants defined in this manner are simply placed directly into your source code, with no variable space allocated in memory. Unfortunately, this is one reason why most debuggers cannot inspect constants created using the #define method.
|
|
|
Category |
C Basics Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8392 users |
Added on |
9/18/2014 |
Views |
70926 |
Rate it! |
|
|
Question:
What is the benefit of using #define to declare a constant ?
Answer:
Using the #define method of declaring a constant enables you to declare a constant in one place and use it throughout your program. This helps make your programs more maintainable, because you need to maintain only the #define statement and not several instances of individual constants throughout your program.
For instance, if your program used the value of pi (approximately 3.14159) several times, you might want to declare a constant for pi as follows:
#define PI 3.14159
Using the #define method of declaring a constant is probably the most familiar way of declaring constants to traditional C programmers. Besides being the most common method of declaring constants, it also takes up the least memory.
Constants defined in this manner are simply placed directly into your source code, with no variable space allocated in memory. Unfortunately, this is one reason why most debuggers cannot inspect constants created using the #define method. Source: CoolInterview.com
#define is used to declare the symbolic constant values.we use the constant values in main function. Source: CoolInterview.com
Answered by: remeena.v | Date: 2/10/2010
| Contact remeena.v
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What are the different storage classes in C ?
|
View Answer
|
|
What is C language ?
|
View Answer
|
|
Difference between "C structure" and "C++ structure".
|
View Answer
|
|
Explain about the following: 1.problem identification 2.task analysis 3.data analysis 5.decision input & output 6.development algorithm 7.program cooling
|
View Answer
|
|
Why two pointers cannot be added in c language?
|
View Answer
|
|
Is the c is procedure oriented?
|
View Answer
|
|
Can you write a c program without using main function?
|
View Answer
|
|
Tell me answer for this statement printf("printf("aim")");
|
- C Basics Interview Questions & Answers">
View Answer
|
|
Difference between :- 1) C and C++ 2) main() in c and main() in c++ ?
|
View Answer
|
|
What is :- Asembler , compiler , Preprocessor , laxical analysis , parsing ?
|
View Answer
|
|
How can we use data connectivity in 'c' language?
|
View Answer
|
|
Write a program for result management system of a college ?
|
View Answer
|
|
Is it possible to print graphics output in C?
|
View Answer
|
|
How can C programs run without header files?
|
View Answer
|
|
What is c graphics?
|
View Answer
|
|
write a program for printing when i press a key next to the letter in the alphabetical order can be printed
|
View Answer
|
|
how to create relation calculator program using c language
|
View Answer
|
|
how to create love flames program using c language
|
View Answer
|
|
Can anyone please tell me about a website from which I could install Turbo C (compiler) for free??
|
View Answer
|
|
What is the use of semicolon at the end of every statement?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C Basics Interview Questions & Answers - Exam Mode /
Learning Mode
|