In C programming, a structure (also called a struct) is a collection of related variables, known as members, grouped together under a single name. It is a user-defined data type that can be used to store a group of data items of different data types.
A structure is defined using the keyword "struct" followed by the name of the structure and a list of members enclosed in curly braces.
Syntax :
struct structure_name
{
datatype member_1 ;
datatype member_2 ;
datatype member_n ;
}
//Structure in C #include<stdio.h> struct student { char *name; int age; float per; }; int main() { struct student o,o2; /* printf("\nSize of Struct : %d",sizeof(o));//4 printf("\nSize of char : %d",sizeof(char));//4 printf("\nSize of int : %d",sizeof(int));//4 printf("\nSize of float : %d",sizeof(float));//4 */ o.name="Tutor Joes"; o.age=30; o.per=85.5; printf("\nName : %s",o.name); printf("\nAge : %d",o.age); printf("\nPercent : %f",o.per); return 0; }To download raw file Click Here
Name : Tutor Joes Age : 30 Percent : 85.500000
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions