[Tutorial 7] 4.Which of the following are invalid variable names? Why?

1. Int char 6_05
2. Calloc Xx alpha_beta_routine
3. floating _1312 z
4. ReInitialize _ A$

1. `Int char 6_05`: This is an invalid variable name. Variable names cannot begin with a digit (`6_05`), and they cannot contain spaces. So, `Int char 6_05` is invalid.

2. `Calloc Xx alpha_beta_routine`: This is a valid variable name. It consists of alphanumeric characters and underscores. Variable names can start with an uppercase letter (`C`), and underscores are allowed.

3. `floating _1312 z`: This is an invalid variable name. While it starts with a valid identifier (`floating`), there's a space after it, making it two separate tokens. Variable names cannot contain spaces. `_1312` is a valid variable name, but `z` is a valid variable name. However, the space between them makes this invalid as a single variable name.

4. `ReInitialize _ A$`: This is an invalid variable name. Variable names cannot contain special characters like `$`. Also, there's a space between `_` and `A$`, which makes it two separate tokens. Variable names cannot contain spaces.

So, to summarize:
- 1. Invalid
- 2. Valid
- 3. Invalid
- 4. Invalid

Comments

Popular posts from this blog

Introduction To C

First C Program

Compilation process in c