Skip to main content

Syntax of struct

Short answer

Syntax: struct tag_name { data_type member1; data_type member2; ... }; then declare variables as struct tag_name var; Example: struct student { char name[20]; int roll; }; struct student s1;

Write the syntax used in C programming language for struct.

struct tag_name {
    data_type member1;
    data_type member2;
    ...
};                          /* semicolon is compulsory */

struct tag_name variable;   /* declaring a variable */

Example:

struct student {
    char name[20];
    int roll;
};
struct student s1;

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 8 questions →