The keyword used to define a structure is _____ A. stru B. stt C. struct D. structure

[amp_mcq option1=”stru” option2=”stt” option3=”struct” option4=”structure” correct=”option4″]

The correct answer is D. structure.

A structure is a user-defined data type that allows you to group together multiple variables of different data types. The keyword used to define a structure is struct.

For example, the following code defines a structure called Person:

struct Person {
int id;
char *name;
float height;
};

A variable of type Person can then be declared as follows:

Person p;

The members of a structure can be accessed using the dot notation. For example, the following code prints the name of the person:

printf("%s\n", p.name);

Structures can also be used to define arrays. For example, the following code defines an array of 10 Person structures:

Person people[10];

The members of an array of structures can be accessed using the array index notation. For example, the following code prints the name of the first person in the array:

printf("%s\n", people[0].name);

Structures are a powerful tool that can be used to represent complex data types. They are often used in conjunction with other data types, such as arrays and pointers.

Exit mobile version