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

Constants in C Programming

The document provides a quiz on constants in C programming, covering definitions, declarations, and characteristics of constants. Key points include that constants are fixed values, declared using the 'const' keyword, and that modifying a const variable results in a compiler error. Additionally, it distinguishes between '#define' and 'const', noting that 'const' is type-checked while '#define' is not.

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 views2 pages

Constants in C Programming

The document provides a quiz on constants in C programming, covering definitions, declarations, and characteristics of constants. Key points include that constants are fixed values, declared using the 'const' keyword, and that modifying a const variable results in a compiler error. Additionally, it distinguishes between '#define' and 'const', noting that 'const' is type-checked while '#define' is not.

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/ 2

Constants

1.​ What is a constant in C?​


a) A variable whose value can be changed​
b) A fixed value that does not change during program execution​
c) A loop counter​
d) A macro with a function​
Answer: b) A fixed value that does not change during program
execution​

2.​ Which keyword is used to declare a constant variable?​


a) final​
b) static​
c) const​
d) define​
Answer: c) const​

3.​ Which of the following defines a symbolic constant?​


a) const int rate = 5;​
b) #define RATE 5​
c) final rate = 5;​
d) rate := 5;​
Answer: b) #define RATE 5​

4.​ Can constants be declared using the const keyword?​


a) Yes​
b) No​
Answer: a) Yes​

5.​ Which of the following is a valid constant declaration?​


a) const int PI = 3.14;​
b) int const = 5;​
c) #const PI = 3.14;​
d) define PI = 3.14;​
Answer: a) const int PI = 3.14;​
6.​ What happens if you try to modify a const variable?​
a) It compiles and runs​
b) Compiler gives an error​
c) It gives a warning​
d) It auto-corrects the value​
Answer: b) Compiler gives an error​

7.​ What is the difference between #define and const?​


a) #define is type-checked​
b) const is pre-processed​
c) const is type-checked, #define is not​
d) Both are the same​
Answer: c) const is type-checked, #define is not​

8.​ Which of these is a floating-point constant?​


a) 5​
b) ‘A’​
c) 5.0​
d) "Hello"​
Answer: c) 5.0​

9.​ What is the scope of a constant defined with #define?​


a) Block​
b) Function​
c) File​
d) Local​
Answer: c) File​

10.​ Can we assign a value to a constant inside a function later?​


a) Yes​
b) No​
Answer: b) No

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy