167k views
1 vote
Which of the following can be used as valid identifiers in C? There may be multiple correct answers.

a. 2float
b. float
c. _float_
d. float2
e. float-2
f. Float

User Elias Naur
by
6.7k points

1 Answer

4 votes

Final answer:

In C, valid identifiers can start with a letter or an underscore, and can contain letters, digits, or underscores. The valid options from the list are _float_, float2, and Float.

Step-by-step explanation:

The question asks which of the following can be used as valid identifiers in C programming. In C, a valid identifier can start with a letter (either uppercase or lowercase) or an underscore, followed by letters, digits, or underscores. Based on these rules:

  • a. 2float - Incorrect, because identifiers cannot start with a digit.
  • b. float - Incorrect, because 'float' is a reserved keyword in C and cannot be used as an identifier.
  • c. _float_ - Correct, as it starts with an underscore and contains only letters and underscores.
  • d. float2 - Correct, as it starts with a letter and is followed by a letter and a digit.
  • e. float-2 - Incorrect, because identifiers cannot contain the hyphen '-' character.
  • f. Float - Correct, as it starts with a letter and is not a reserved keyword in C.

Thereby, the valid identifiers from the options provided are c. _float_, d. float2, and f. Float.

User Syco
by
7.2k points