1)

Which is the best way to define a value 5.28 in a variable ‘pi’ where value cannot be modified ?


A) #define pi 5.28F

B) pi = 5.28F

C) const float pi = 5.28F

D) const float pi; pi = 5.28F

Answer:

Option C

Explanation:

Const keyword is used for the constant variables with fixed value and any modification in its value will throw an error. Hence, options a, b and d are rejected because value is not declared fixed. So, const float pi = 5.28F is the correct way of declaration of constant variable.