Which of the following variable names is correct?Question 6Answerint.ageAll variable names are wrongint(Age)_intAge
Question
Which of the following variable names is correct?Question 6Answerint.ageAll variable names are wrongint(Age)_intAge
Solution
Para determinar cuál de los nombres de variables es correcto, debemos seguir las reglas de nomenclatura de variables:
- No pueden comenzar con un número.
- No pueden contener caracteres especiales como paréntesis, guiones, etc., excepto el guion bajo (_).
- No pueden ser palabras reservadas del lenguaje de programación.
Analicemos cada opción:
int.age: Incorrecto. El punto (.) no es permitido en los nombres de variables.int(Age): Incorrecto. Los paréntesis no son permitidos en los nombres de variables._intAge: Correcto. Cumple con todas las reglas de nomenclatura.All variable names are wrong: Incorrecto. Ya que_intAgees un nombre de variable válido.
Por lo tanto, la respuesta correcta es _intAge.
Similar Questions
Which is a valid C variable declaration?Question 5Select one:a.int main;b.int $name;c.int age;d.int &temp;e.int name#;
Which of the following are valid Python variable names:Agever1.3route664squarereturnhome_address
Which of the following are requirements for variable names?
Which of the following is wrong in reference to naming of variable? Mark(1 Marks)(Choose one option)Keywords are not allowed for variable namesVariable names can start from numberSpaces are not allowed for variable namesSpecial symbols are not allowed
Write down the reasons of the following invalid variable names:
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.