---
title: "Structure tag"
subject: "Computer Programming"
chapter: 8
key: "semester_1/computer_programming:structure-tag"
source: https://www.bctengineer.com/q/semester_1/computer_programming/structure-tag
site: BCT Engineering
---

# Structure tag

Computer Programming · Chapter 8: Structures

- Asked in: 2071 Chaitra, 1+1+2 marks
- Video: [Structure Types (Using Structure Tags)](https://www.youtube.com/watch?v=IPLPISOXvF0) — Neso Academy
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/structure-tag
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-8

## Question

What is a tag? Must a tag be included in a structure type definition? Must a tag be included in a structure variable declaration? Explain.

## Short answer

A tag is the optional name after struct that names the type. It is not mandatory in the definition if variables are declared simultaneously (struct { int x; } p;). In separate variable declarations, the tag must be included (struct student s1;). If typedef is used, the tag can be omitted.

## Answer

#### What is a tag?
A **tag** is the optional name written after the keyword `struct` in a structure definition. It names the structure type, so that the type can be used again later.

```c
struct student {        /* "student" is the tag */
    char name[20];
    int roll;
};
```

#### Must a tag be included in the structure definition?
No. A structure can be defined without a tag, but then variables must be declared at the same time (in the definition), and the type cannot be used again later because it has no name.

```c
struct { int x, y; } p;     /* no tag, variable p declared here */
```

#### Must a tag be included in a variable declaration?
Yes, when the variable is declared separately from the definition, the tag is needed along with `struct`, as in `struct student s1;`. If the variable is declared together with the definition (`struct {...} p;`) no tag is needed. With `typedef`, the new type name can replace `struct tag`.

```c
#include <stdio.h>

struct book {                /* "book" is the tag */
    char title[30];
    float price;
} b1;                        /* variable declared with the definition */

struct book b2;              /* variable declared later using the tag */

struct {                     /* no tag: variable must be declared here */
    int x, y;
} p;

int main(void)
{
    b1.price = 250;
    b2.price = 300;
    p.x = 1;
    printf("%.0f %.0f %d\n", b1.price, b2.price, p.x);
    return 0;
}
```

Output: `250 300 1`

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a tag?
   A. A variable of the structure
   B. The optional name after struct that names the structure type
   C. A member of the structure
   D. A header file
   Answer: B. The tag allows the type to be reused. (Key point: Tag meaning)

2. Must a tag be included in a structure definition?
   A. Yes, always
   B. No, and the type can be reused later
   C. No, but then variables must be declared in the definition itself
   D. Yes, but only with typedef
   Answer: C. Without a tag the type has no name for later use. (Key point: Tag in definition)

3. When is the tag needed in a separate variable declaration?
   A. Never
   B. Only for arrays
   C. Only for pointers
   D. Always for a separate declaration: struct student s1;
   Answer: D. The type is found by struct + tag. (Key point: Tag in declaration)

4. What can replace 'struct tag' in declarations?
   A. A typedef name
   B. A macro in stdio.h
   C. The tag alone without struct, always
   D. A semicolon
   Answer: A. typedef gives the structure a type name. (Key point: Typedef)

## Related in Computer Programming

- [Variable declaration versus definition](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adeclaration-vs-definition) — Computer Programming, chapter 3
- [Declaration vs definition; C program structure](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adeclaration-definition-structure-of-c) — Computer Programming, chapter 3

## Related in other subjects

- [Org structure definition; line organization pros/cons](https://www.bctengineer.com/question.md?key=semester_7%2Forganization_and_management%3Aorg-structure-define-line) — Organization and Management, chapter 5
