Structure in C by R4R Team

Structure:
-It is collection of different value having different data types.

Array vs Structure:
Array is a collection of same data type while structure have capability to store different data type.

Syntax-
struct name
{
data types;
};

-Here struct is the keyword that are use to initialize the structure.

Example-

struct Mydata
{
char name[20];
int age;
float salary;
};

Store and access data in structure:

program-

#include< stdio.h>
struct r4r
{
int x;
char ch;
};
int main()
{
//store value with object.
struct r4r obj;
// Accessing members of point p1
obj.x=10;
obj.ch="a";
printf ("%d %d", obj.x, obj.y);
return 0;
}


output-

10 a




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!