MCQ Single Best Answer Not Set

QWhich of the following is the correct way to set a value 3.14 in a variable pi such that it cannot be modified?

ID: #906 Data Types in C Language 11,872 views
Question Info
#906Q ID
Not SetDifficulty
Data Types in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A pi = 3.14F;
  • B const float pi = 3.14F;
  • C const pi; pi = 3.14F;
  • D float pi = 3.14F;
Correct Answer: Option B

Explanation

pi = 3.14F; It doesn't declare the data type.

const float pi = 3.14F; is the correct Answer. It declare constant datatype.

const pi; pi = 3.14F; Here data type doesn't declare.

float pi = 3.14F; pi is a floating-point variable but not a constant.

Share This Question

Challenge a friend or share with your study group.