TCS
Company
Programming
Variables
How many of the following are invalid
variable name?
NUMBER
first.name
midname. _num 93num
num93
last name nUMBER
4321
1. 5
2. 3
3. 2
4. More than 5
Read Solution (Total 15)
-
- No of invalid variable is 4. the nvalid variables are the following
first.name // special character other than '_' is not allowed
midname._num 93num // special character other than '_' is not allowed
last name nUMBER //space is not allowed
4321 // variable name should start with either an alphabet or '_' character - 6 years agoHelpfull: Yes(9) No(1)
- All variable names must begin with a letter of the alphabet or an. underscore( _ ). ...
After the first initial letter, variable names can also contain letters and numbers. ...
Uppercase characters are distinct from lowercase characters. ...
You cannot use a C++ keyword (reserved word) as a variable name.
soo 3 of these are invalid
ans:-option 2 - 6 years agoHelpfull: Yes(4) No(2)
- #include
int main()
{
Int a, b;
Printf("enter the values if a and b") ;
Scanf("%d %d", &a, & b) ;
b=a+b;
a=b-a;
b=b-a;
printf("%d%d", a, b) ;
Return(0);
} - 6 years agoHelpfull: Yes(4) No(3)
- Characters Allowed :
Underscore(_)
Capital Letters ( A – Z )
Small Letters ( a – z )
Digits ( 0 – 9 )
Blanks & Commas are not allowed
No Special Symbols other than underscore(_) are allowed
First Character should be alphabet or Underscore
Variable name Should not be Reserved Word.
Dot(.), Spaces are not allowed in variable names so answer is option 1 - 6 years agoHelpfull: Yes(3) No(1)
- Ans:1
Because variable name must start with _ or
Alphabet
. And spaces not allowed in variable name - 6 years agoHelpfull: Yes(1) No(1)
- 4
because no special characters are allowed - 6 years agoHelpfull: Yes(1) No(1)
- ans-option 2
because, var name should no starts with numerics and var name doesnot accepts space so 3 variable names in the list are invalid - 6 years agoHelpfull: Yes(1) No(0)
- a variable name should not start with a capital letter,number or any symbol except undercore and space is not allowed
hence,the answer is 5 - 5 years agoHelpfull: Yes(1) No(1)
- Ans will be 1.5
- 6 years agoHelpfull: Yes(0) No(2)
- answer: Option 2. 3
because variable names can be started only with alphabets or underscores.
There should be no spaces present in between the variable name - 6 years agoHelpfull: Yes(0) No(1)
- two variable declarations are ok.Because of only these two follow variable name declaration rules
- 6 years agoHelpfull: Yes(0) No(0)
- i think its 3
- 5 years agoHelpfull: Yes(0) No(0)
- Characters Allowed :
Underscore(_)
Capital Letters ( A – Z )
Small Letters ( a – z )
Digits ( 0 – 9 )
Blanks & Commas are not allowed
No Special Symbols other than underscore(_) are allowed
First Character should be alphabet or Underscore
Variable name Should not be Reserved Word. - 5 years agoHelpfull: Yes(0) No(0)
- ans- option 1
- 5 years agoHelpfull: Yes(0) No(0)
- 4 are invalid
first.name
midname._num 93num
last name nUMBER
4321
these are against the string rules. A string does not have space or (.) or number in it - 3 years agoHelpfull: Yes(0) No(0)
TCS Other Question