Showing posts with label Structure. Show all posts
Showing posts with label Structure. Show all posts

Tuesday, April 19, 2016

Defining a Structure

Defining a Structure

Defining a Structure is a process of creating the skeleton of physical object that can be understood by compiler .It consists of Structure name and the description of it’s member(property).

Definition of a structure creates a template are format that describes the characteristics of it’s member .

The general syntax of a structure definition is:
Struct structurename{
               Datatype member1;
               Datatype member2;
               …………………………………..
               Datatype membern; 
                        };
Here struct is a keyword , which tells the compiler that a structure is being defined . member1 , member2 ,………,membern are the member of structure and are declared inside curly bracket .
There should be a semicolon at the end of the curly braces

These member can be of any data type like int , char , float , array , pointer or another structure

Structurename is the name of the structure and is used further in the program to declare Structure variables of this types

Definition of a structure provides and more data type that can be used in program

It is important to note that definition of structure does not reserve any space in memory for the members.Although the syntax of the declaration of member inside the definition of Structure is identical to the syntax we use in declaring variables but they are not variables . They do not have any existence until they are attached with a structure variables.

The member name should be different inside the structure definition but it can be same outside the Structure definition and inside other Structure definition.

Let us take an example of defining the Structure :

e.g:
struct man{
           char name[21];
           int rollno;
           float salary;
                };
Here man is the Structure name and there are three member i.e name, rollno , salary
.
Structure can be defined globally or locally




You can Browse related article below for more information and program code related to Structure  Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required


Defining a Structure


Wednesday, March 16, 2016

Structure Learning for both novices and advanced programmers

Structure

The meaning of structure is the quality of being organized in general term. To understand the structure in programming language you must be able to link it with general meaning
  • 1) How can we link it with general meaning?
  • 2) What is structure in c?
In programming structure is the collection of various data of different data type. We can connect it with the class of java or other OOP language. As class has object which have property and method, But here we have an object and its property or value.

Structure helps to bring real physical object into virtual computer world.

A simple structure can be
Student with property 1) Name 2) Roll number 3) Age etc.
Structure

  • 1) How structure is different from array and variable?

  • 2) What is advantage of structure?
Structure is used for data handling operation.
It can be good to think that there are already other syntax that can handle data, then why is the need of Structure.


The main advantage of structure is that it can group different types of logically related data .

For example if you want to create a record of a person that contains name, age and height of that person, then we can’t use array because all the three data elements are of different data types.

To store these related fields of different data types we can use a structure, which is capable of storing heterogeneous data.

Data of different types can be grouped together under a single name using structure.

The data elements of a structure are referred to as member (property)

You can Browse related article below for more information and program code related to Structure  Does above is helpful , Post you views in comment

DO NOT MISS OTHER C PROGRAMMING TUTORIAL

* indicates required


Structure Learning for both novices and advanced programmers