0% found this document useful (0 votes)
9 views3 pages

Defining Symbolic Constants

The document discusses symbolic constants in C programming, highlighting the use of the preprocessor directive '#define' for their definition. It explains their advantages, such as improved readability and easier maintenance, and notes that they are replaced by their values during preprocessing. Additionally, it covers common practices and incorrect methods for defining symbolic constants, along with their application in code examples.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Defining Symbolic Constants

The document discusses symbolic constants in C programming, highlighting the use of the preprocessor directive '#define' for their definition. It explains their advantages, such as improved readability and easier maintenance, and notes that they are replaced by their values during preprocessing. Additionally, it covers common practices and incorrect methods for defining symbolic constants, along with their application in code examples.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

defining Symbolic Constants

1.​ Which preprocessor directive is used to define symbolic constants in


C?​

○​ a) include
○​ b) define
○​ c) const
○​ d) typedef
○​ Answer: b) define
2.​ What is the correct syntax for defining a symbolic constant PI with
the value 3.14159?​

○​ a) const PI = 3.14159;
○​ b) define PI 3.14159;
○​ c) #define PI 3.14159
○​ d) #symbol PI = 3.14159
○​ Answer: c) #define PI 3.14159
3.​ Symbolic constants are replaced by their values during:​

○​ a) Compilation
○​ b) Linking
○​ c) Preprocessing
○​ d) Execution
○​ Answer: c) Preprocessing
4.​ What is the advantage of using symbolic constants?​

○​ a) Improved readability
○​ b) Easier maintenance
○​ c) Both a and b
○​ d) None of the above
○​ Answer: c) Both a and b
5.​ Symbolic constants are also known as:​

○​ a) Variables
○​ b) Macros
○​ c) Functions
○​ d) Pointers
○​ Answer: b) Macros
6.​ Which of the following is an incorrect way to define a symbolic
constant?​

○​ a) #define SIZE 100


○​ b) #define PI 3.14
○​ c) define SIZE 100;
○​ d) #define MESSAGE "Hello"
○​ Answer: c) define SIZE 100;

What is the output of the following code?​



C​
#define VALUE 5
int main() {
printf("%d", VALUE * 2);
return 0;
}

7.​
○​ a) 5
○​ b) 10
○​ c) 2
○​ d) 0
○​ Answer: b) 10
8.​ Symbolic constants are typically written in:​

○​ a) Lowercase
○​ b) Uppercase
○​ c) CamelCase
○​ d) snake_case
○​ Answer: b) Uppercase
9.​ Can symbolic constants be used in expressions?​
○​ a) Yes
○​ b) No
○​ c) Only in simple expressions
○​ d) Only in loops
○​ Answer: a) Yes
10.​ What is the benefit of using symbolic constants for array sizes?​

○​ a) Increased execution speed


○​ b) Easy to change the array size in one place
○​ c) Reduced memory usage
○​ d) Improved error handling
○​ Answer: b) Easy to change the array size in one place

You might also like