What is the structure?
Long Answer
Views 552
Answer:
- The structure is a user-defined data type that allows storing multiple types of data in a single unit. It occupies the sum of the memory of all members.
- The structure members can be accessed only through structure variables.
- Structure variables accessing the same structure but the memory allocated for each variable will be different.
struct structure_name { Member_variable1; Member_variable2 . . }[structure variables];
Let's see a simple example.
Output:#include struct student { char name[10]; // structure members declaration. int age; }s1; //structure variable int main() { printf("Enter the name"); scanf("%s",s1.name); printf("\n"); printf("Enter the age"); scanf("%d",&s1.age); printf("\n"); printf("Name and age of a student: %s,%d",s1.name,s1.age); return 0; }
Enter the name shikha Enter the age 26 Name and age of a student: shikha,26
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of C Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.